Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After some consideration and reading some documentation about caching I moved to simpler solution which doesn't require modifing django:</p> <ul> <li>add middleware Subdomain as provided below</li> </ul> <blockquote> <pre><code>class Subdomains: def process_request(self, request): request.META['HTTP_X_SUBDOMAIN'] = request.get_host() def process_response(self, request, response): response['X-Subdomain'] = request.META['HTTP_X_SUBDOMAIN'] return response </code></pre> </blockquote> <ul> <li>add middleware to Your middleware classes in settings.py (watch out for django.contrib.messages.middleware.MessageMiddleware and django.contrib.auth.middleware.AuthenticationMiddleware + session wide caching <a href="https://code.djangoproject.com/ticket/6552" rel="nofollow">issue</a>)</li> </ul> <blockquote> <pre><code>MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.gzip.GZipMiddleware', 'middleware.default.Subdomains', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # we need that to make auth middleware not to add Vary: Cookie to each response 'django.middleware.cache.FetchFromCacheMiddleware', ) </code></pre> </blockquote> <ul> <li>in views use</li> </ul> <blockquote> <p>from django.views.decorators.vary import vary_on_headers</p> <p>@vary_on_headers('X-Subdomain')</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload