[Django] #22827: Per-site cache docs vague about which middleware sets headers

2 views
Skip to first unread message

Django

unread,
Jun 13, 2014, 5:35:20 AM6/13/14
to django-...@googlegroups.com
#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.

Django

unread,
Jun 13, 2014, 7:28:23 AM6/13/14
to django-...@googlegroups.com
#22827: Per-site cache docs vague about which middleware sets headers
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: nobody
<django@…> | Status: new
Type: | Version: master
Cleanup/optimization | Resolution:
Component: Documentation | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/22827#comment:1>

Django

unread,
Jul 25, 2014, 4:43:51 AM7/25/14
to django-...@googlegroups.com
#22827: Per-site cache docs vague about which middleware sets headers
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: nobody
<django@…> | Status: new
Type: | Version: master
Cleanup/optimization | Resolution:
Component: Documentation | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0

Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by mardini):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/2955
Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/22827#comment:2>

Django

unread,
Jul 25, 2014, 6:26:19 AM7/25/14
to django-...@googlegroups.com
#22827: Per-site cache docs vague about which middleware sets headers
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: nobody
<django@…> | Status: closed
Type: | Version: master
Cleanup/optimization | Resolution: fixed

Component: Documentation | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"f9b7a0383c6f0fbadb83306db667675d9f9dd2b4"]:
{{{
#!CommitTicketReference repository=""
revision="f9b7a0383c6f0fbadb83306db667675d9f9dd2b4"
Fixed #22827 -- clarified what each cache middleware does.

Thanks Keryn Knight for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22827#comment:3>

Django

unread,
Jul 25, 2014, 6:28:16 AM7/25/14
to django-...@googlegroups.com
#22827: Per-site cache docs vague about which middleware sets headers
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: nobody
<django@…> | Status: closed
Type: | Version: master
Cleanup/optimization | Resolution: fixed
Component: Documentation | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d8961a5ad05b103b7b37e8e7a992f5d2f761fc2c"]:
{{{
#!CommitTicketReference repository=""
revision="d8961a5ad05b103b7b37e8e7a992f5d2f761fc2c"
[1.7.x] Fixed #22827 -- clarified what each cache middleware does.

Thanks Keryn Knight for the report.

Backport of f9b7a0383c from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22827#comment:4>

Reply all
Reply to author
Forward
0 new messages