Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add ability to cache by response content, check if response was actually changed even if it expired, return same headers on 304 and 200#13274

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
OlegYch wants to merge1 commit intoplayframework:main
base:main
Choose a base branch
Loading
fromOlegYch:master

Conversation

OlegYch
Copy link
Contributor

@OlegYchOlegYch commentedMay 19, 2025
edited
Loading

The primary reason for this is to increase performance by decreasing the amount of result content returned from server side and utilizing 304 response headers to drive the client to make less requests.

This also brings Cached implementation closer to http spec by:

  1. actually using response content as described byhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag
  2. preserving headers as described byhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/304

For performance reasons this still uses two cache entries per resource, to avoid retrieving potentially large result content from potentially remote cache.

For compatibility reasons new ability is gated viaplay.cache.hashResponse config entry. It should probably become default in the future as the old ETag value based on expiration date (essentially random value) doesn't seem to be useful or specified anywhere in http. The config value and relevant code should be removed then.

cc@julienrf as the original author
cc@alexdupre as the most recent functionality contributor

@mkurz
Copy link
Member

Is there any issue or related PR?

@OlegYch
Copy link
ContributorAuthor

@mkurz not that i've seen

mkurz reacted with thumbs up emoji

@alexdupre
Copy link
Contributor

I support the change from a conceptual point of view, it's a noticeable improvement. I looked at the commit briefly, I'd suggest to create the hash of the response content in a streamed way (e.g. via aDigestOutputStream), instead of materializing the entire byte array, though.

…lly changed even if it expired, return same headers on 304 and 200This brings Cached implementation closer to http spec by:1. actually using response content as described byhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag2. preserving headers as described byhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/304For performance reasons this still uses two cache entries per resource, to avoid retrieving potentially large result content from potentially remote cache.For compatibility reasons new ability is gated via `play.cache.hashResponse` config entry.It should probably become default in the future as the old ETag value based on expiration date (essentially random value) doesn't seem to be useful or specified anywhere in http.The config value and relevant code should be removed then.
@OlegYch
Copy link
ContributorAuthor

@alexdupre makes sense, updated

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@OlegYch@mkurz@alexdupre

[8]ページ先頭

©2009-2025 Movatter.jp