[Django] #36560: When the Cache-Control header is set to no-store, the response is cached.

12 views
Skip to first unread message

Django

unread,
Aug 19, 2025, 5:02:17 AM8/19/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
-------------------------------------+-------------------------------------
Reporter: mengxunQAQ | Type: Bug
Status: new | Component: Core
| (Cache system)
Version: 5.2 | Severity: Normal
Keywords: cache | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
{{{
from django.http import HttpResponse
import datetime

def cache_demo(request):
resp = HttpResponse(f"Current content at {datetime.datetime.now()}")
resp["Cache-Control"] = "no-store"
return resp

}}}
Based on the example above, when the Cache-Control header is set to no-
store, the response content is still cached.
--
Ticket URL: <https://code.djangoproject.com/ticket/36560>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 19, 2025, 5:16:43 AM8/19/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
-------------------------------------+-------------------------------------
Reporter: mengxunQAQ | Owner: (none)
Type: Bug | Status: new
Component: Core (Cache system) | Version: 5.2
Severity: Normal | Resolution:
Keywords: cache | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by mengxunQAQ:

Old description:

> {{{
> from django.http import HttpResponse
> import datetime
>
> def cache_demo(request):
> resp = HttpResponse(f"Current content at {datetime.datetime.now()}")
> resp["Cache-Control"] = "no-store"
> return resp
>
> }}}
> Based on the example above, when the Cache-Control header is set to no-
> store, the response content is still cached.

New description:

**settings.py**
{{{
...
MIDDLEWARE = [
"django.middleware.cache.UpdateCacheMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.cache.FetchFromCacheMiddleware",
]
...
}}}

**views.py**
{{{
from django.http import HttpResponse
import datetime

def cache_demo(request):
resp = HttpResponse(f"Current content at {datetime.datetime.now()}")
resp["Cache-Control"] = "no-store"
return resp

}}}

Based on the example above, when the Cache-Control header is set to no-
store, the response content is still cached.

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

Django

unread,
Aug 19, 2025, 10:56:52 AM8/19/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
--------------------------------------+------------------------------------
Reporter: mengxun | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution:
Keywords: cache | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Sarah Boyce):

* component: Core (Cache system) => HTTP handling
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization

Comment:

Similar to #28833, can work around by using @never_cache
--
Ticket URL: <https://code.djangoproject.com/ticket/36560#comment:2>

Django

unread,
Aug 20, 2025, 1:54:39 AM8/20/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
-------------------------------------+-------------------------------------
Reporter: mengxun | Owner:
Type: | jagadeshanh
Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution:
Keywords: cache | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jagadeshanh):

* owner: (none) => jagadeshanh
* status: new => assigned

Comment:

I can work on these changes
--
Ticket URL: <https://code.djangoproject.com/ticket/36560#comment:3>

Django

unread,
Aug 20, 2025, 1:57:59 AM8/20/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
--------------------------------------+------------------------------------
Reporter: mengxun | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution:
Keywords: cache | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by jagadeshanh):

* owner: jagadeshanh => (none)
* status: assigned => new

Comment:

Seems like, someone has already raised a PR
--
Ticket URL: <https://code.djangoproject.com/ticket/36560#comment:4>

Django

unread,
Aug 20, 2025, 3:13:37 AM8/20/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
--------------------------------------+------------------------------------
Reporter: mengxun | Owner: mengxun
Type: Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution:
Keywords: cache | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Sarah Boyce):

* owner: (none) => mengxun
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36560#comment:5>

Django

unread,
Aug 20, 2025, 3:13:54 AM8/20/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
--------------------------------------+------------------------------------
Reporter: mengxun | Owner: mengxun
Type: Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution:
Keywords: cache | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Sarah Boyce):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36560#comment:6>

Django

unread,
Aug 20, 2025, 3:39:36 AM8/20/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
-------------------------------------+-------------------------------------
Reporter: mengxun | Owner: mengxun
Type: | Status: assigned
Cleanup/optimization |
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution:
Keywords: cache | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36560#comment:7>

Django

unread,
Aug 21, 2025, 10:48:48 AM8/21/25
to django-...@googlegroups.com
#36560: When the Cache-Control header is set to no-store, the response is cached.
-------------------------------------+-------------------------------------
Reporter: mengxun | Owner: mengxun
Type: | Status: closed
Cleanup/optimization |
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution: fixed
Keywords: cache | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

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

Comment:

In [changeset:"ed7c1a56400d64f109f30df3ce697984cdad7c75" ed7c1a56]:
{{{#!CommitTicketReference repository=""
revision="ed7c1a56400d64f109f30df3ce697984cdad7c75"
Fixed #36560 -- Prevented UpdateCacheMiddleware from caching responses
with Cache-Control 'no-cache' or 'no-store'.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36560#comment:8>
Reply all
Reply to author
Forward
0 new messages