Opened 3 months ago
Closed 3 months 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 )
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 , 3 months ago
| Description: | modified (diff) |
|---|
comment:2 by , 3 months ago
| Component: | Core (Cache system) → HTTP handling |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Bug → Cleanup/optimization |
comment:4 by , 3 months ago
| Owner: | removed |
|---|---|
| Status: | assigned → new |
Seems like, someone has already raised a PR
comment:5 by , 3 months ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:6 by , 3 months ago
| Has patch: | set |
|---|
comment:7 by , 3 months ago
| Needs tests: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
Similar to #28833, can work around by using @never_cache