Opened 3 months ago
Last modified 3 months 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 )
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.
Note:
See TracTickets
for help on using tickets.