Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add caching headers to unmodified static resources #34614

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yuzawa-san
Copy link
Contributor

I was playing around with a CDN and noticed some interesting behavior. It was caching using the original Cache-Control max-age on the original 200, but when a refresh and 304 was returned by spring, the Cache-Control was missing, so the caching proxy used its default max-age (which was longer than my original max-age). I found this https://stackoverflow.com/questions/1587667/should-http-304-not-modified-responses-contain-cache-control-headers which pointed me at https://www.rfc-editor.org/rfc/rfc7232#section-4.1 which states:

The server generating a 304 response MUST generate any of the following header fields that would have been sent in a 200 (OK) response to the same request: Cache-Control, Content-Location, Date, ETag, Expires, and Vary.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 18, 2025
per https://www.rfc-editor.org/rfc/rfc7232#section-4.1

The server generating a 304 response MUST generate any of the
following header fields that would have been sent in a 200 (OK)
response to the same request: Cache-Control, Content-Location, Date,
ETag, Expires, and Vary.

Signed-off-by: James Yuzawa <jtyuzawa@gmail.com>
@yuzawa-san yuzawa-san force-pushed the static-304-caching-headers branch from 127b2ec to c8a082d Compare March 18, 2025 01:19
@bclozel bclozel self-assigned this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants