Skip to content

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
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 5, 2025
@bclozel bclozel added this to the 6.2.8 milestone Jun 5, 2025
@bclozel bclozel closed this in aa5c0dc Jun 5, 2025
@bclozel
Copy link
Member

bclozel commented Jun 5, 2025

Thanks for your contribution @yuzawa-san !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants