Opened 8 weeks ago

Closed 8 weeks ago

#36560 closed Cleanup/optimization (fixed)

When the Cache-Control header is set to no-store, the response is cached.

Reported by: mengxun Owned by: mengxun
Component: HTTP handling Version: 5.2
Severity: Normal Keywords: cache
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by mengxun)

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.

Change History (8)

comment:1 by mengxun, 8 weeks ago

Description: modified (diff)

comment:2 by Sarah Boyce, 8 weeks ago

Component: Core (Cache system)HTTP handling
Needs tests: set
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Similar to #28833, can work around by using @never_cache

comment:3 by Jagadesha NH, 8 weeks ago

Owner: set to Jagadesha NH
Status: newassigned

I can work on these changes

comment:4 by Jagadesha NH, 8 weeks ago

Owner: Jagadesha NH removed
Status: assignednew

Seems like, someone has already raised a PR

comment:5 by Sarah Boyce, 8 weeks ago

Owner: set to mengxun
Status: newassigned

comment:6 by Sarah Boyce, 8 weeks ago

Has patch: set

comment:7 by Sarah Boyce, 8 weeks ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:8 by Sarah Boyce <42296566+sarahboyce@…>, 8 weeks ago

Resolution: fixed
Status: assignedclosed

In ed7c1a56:

Fixed #36560 -- Prevented UpdateCacheMiddleware from caching responses with Cache-Control 'no-cache' or 'no-store'.

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