Opened 11 months ago

Closed 9 months ago

Last modified 9 months ago

#22827 closed Cleanup/optimization (fixed)

Per-site cache docs vague about which middleware sets headers

Reported by: Keryn Knight <django@…> Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The 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 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 FetchFromCacheMiddleware at the beginning of the request

Change History (4)

comment:1 Changed 11 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 9 months ago by mardini

  • Has patch set

comment:3 Changed 9 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In f9b7a0383c6f0fbadb83306db667675d9f9dd2b4:

Fixed #22827 -- clarified what each cache middleware does.

Thanks Keryn Knight for the report.

comment:4 Changed 9 months ago by Tim Graham <timograham@…>

In d8961a5ad05b103b7b37e8e7a992f5d2f761fc2c:

[1.7.x] Fixed #22827 -- clarified what each cache middleware does.

Thanks Keryn Knight for the report.

Backport of f9b7a0383c from master

Note: See TracTickets for help on using tickets.
Back to Top