I have several sites under one Django application in which I would like to implement caching on the site. However, this proves that this is a real hassle.
what happens is that settings.CACHE_MIDDLEWARE_KEY_PREFIX set once at startup, and I cannot go further and change it depending on what the current site is. As a result, if the url page http://website1.com/abc/ cached, then http://website2.com/abc/ displays the cached version of http://website1.com/abc/ . Both of these websites run on the same instance of Django, as this is what allows us to make Django Sites.
Is this the wrong approach? Since at runtime I cannot dynamically set CACHE_MIDDLEWARE_KEY_PREFIX , I cannot cache multiple sites using Django site caching. I also can not do this for the template and view caching.
I get the impression that the way that this really needs to be set up is that each site needs its own instance of Django, which is pretty much identical, except for the settings file, which in my case will differ only by the value CACHE_MIDDLEWARE_KEY_PREFIX . These instances Django all read and write to the same database. It concerns me, as this can create a number of new problems.
Am I following the right path, or am I mistaken about how to work with the architecture of several sites? I checked the Django docs and there is no real mention of how to handle caching (i.e. not low level caching) for Django applications serving multiple sites.
django django-caching django-sites
Werda
source share