Opened 8 years ago
Closed 10 months ago
#27225 closed Bug (fixed)
"age" header is not set for responses taken from cache.
Reported by: | Rinat Khabibiev | Owned by: | Alexander Lazarević |
---|---|---|---|
Component: | HTTP handling | Version: | 1.10 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When fetching response from the cache, 'Cache-Control' contains 'max-age' corresponding to the moment of original response generation time, thus for another time it usually doesn't match 'Expires' value.
Change History (15)
comment:1 by , 8 years ago
Status: | new → assigned |
---|
comment:2 by , 8 years ago
comment:3 by , 8 years ago
Exactly, and that's why it is a bug.
It would be correct behavior if response include Date header corresponding to original response generation time. But I'm not sure
comment:4 by , 8 years ago
RFC7234 says about Age header which indicates age of the cache, so instead of Cache-Control's max-age regeneration it is possible to set Age. Also there is good visual explanation how browser cache should work: https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#Freshness
comment:5 by , 8 years ago
My understanding is that the current pull request fix isn't correct then, right?
comment:9 by , 8 years ago
Patch needs improvement: | set |
---|
I left comments for improvement on the PR. Please uncheck "Patch needs improvement" after updating it.
comment:10 by , 10 months ago
Owner: | changed from | to
---|
Created a new (draft) PR: https://github.com/django/django/pull/17726
This one contains not yet all recommended changes from the original PR: https://github.com/django/django/pull/7246
comment:13 by , 10 months ago
Summary: | Cache-Control's max-age doesn't match Expires for responses taken from cache → "age" header is not set for responses taken from cache. |
---|
comment:14 by , 10 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
I'm not sure if the proposed behavior is correct. From RC2616 sec14.9.3 (which I only skimmed, so please provide another reference if it's wrong):
I think I understand the idea behind the PR, however, it seems to treat the Expires as authoritative rather than max-age.