Opened 5 weeks ago

Last modified 4 weeks ago

#36560 closed Cleanup/optimization

When the Cache-Control header is set to no-store, the response is cached. — at Version 1

Reported by: mengxun Owned by:
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 (1)

comment:1 by mengxun, 4 weeks ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top