#22827: Per-site cache docs vague about which middleware sets headers
-----------------------------------------+--------------------
     Reporter:  Keryn Knight <django@…>  |      Owner:  nobody
         Type:  Cleanup/optimization     |     Status:  new
    Component:  Documentation            |    Version:  master
     Severity:  Normal                   |   Keywords:
 Triage Stage:  Unreviewed               |  Has patch:  0
Easy pickings:  0                        |      UI/UX:  0
-----------------------------------------+--------------------
 The [https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-
 cache docs] currently say:

 > Additionally, the cache middleware automatically sets a few headers in
 each HttpResponse:
 >
 > Sets the Last-Modified header to the current date/time when a fresh (not
 cached) version of the page is requested.
 > Sets the Expires header to the current date/time plus the defined
 CACHE_MIDDLEWARE_SECONDS.
 > Sets the Cache-Control header to give a max age for the page – again,
 from the CACHE_MIDDLEWARE_SECONDS setting.

 It's no longer clear ''which'' middleware does that, because these days
 what was once `CacheMiddleware` is now recommended as two separate
 components, `UpdateCacheMiddleware` and `FetchFromCacheMiddleware`. It is
 the
 
[https://github.com/django/django/blob/c083e3815aec23b99833da710eea574e6f2e8566/django/middleware/cache.py#L99
 UpdateCacheMiddleware] that is responsible for modifying the Response's
 headers.

 And, if being really picky:

 > The cache middleware caches GET and HEAD responses with status 200,
 where the request and response headers allow

 This is dictated by the
 
[https://github.com/django/django/blob/c083e3815aec23b99833da710eea574e6f2e8566/django/middleware/cache.py#L129
 FetchFromCacheMiddleware] at the beginning of the request

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22827>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/080.cf044e569313f8d5008418c82f3b01fe%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to