-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Set the LastModified header for raw files #18356
Set the LastModified header for raw files #18356
Conversation
Although the use of LastModified dates for caching of git objects should be discouraged (as it is not native to git - and there are a LOT of ways this could be incorrect) - LastModified dates can be a helpful somewhat more human way of caching for simple cases. This PR adds this header and handles the If-Modified-Since header to the /raw/ routes. Fix go-gitea#18354 Signed-off-by: Andrew Thornton <art27@cantab.net>
Codecov Report
@@ Coverage Diff @@
## main #18356 +/- ##
=======================================
Coverage ? 46.03%
=======================================
Files ? 840
Lines ? 92931
Branches ? 0
=======================================
Hits ? 42779
Misses ? 43354
Partials ? 6798
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, if this is going to cause major problems, we should revert this PR. But from the code it's looking good, it should send a new copy of the file when CommitterDate is changed, which should be sufficient to have good caching.
Signed-off-by: Andrew Thornton <art27@cantab.net>
…ader-raw' into fix-18354-set-last-modified-header-raw
It's a very poor cache and could lead to things being cached when they shouldn't be - for example if there has been a force-push. However if you want to use LastModified instead of the etag then this is the risk you take. I guess we need to ask what @silverwind thinks - my only worry is that Browsers start sending both and the IfModifiedSince incorrectly detects no change when there is one. |
What do you mean sending both? |
I mean an HTTP Request sends both |
Actually I guess this just means we should deal with both headers at the same time. |
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match Official ref: https://httpwg.org/specs/rfc7232.html#precedence |
Browsers by default send none of the headers. If they encounter |
…dified-header-raw
So if we send both If so this code is likely incorrect and we need to make it so that we only pay attention to If-Modified-Since iff |
Signed-off-by: Andrew Thornton <art27@cantab.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
How about work on #18448 ? IIRC |
🚀 |
* giteaofficial/main: Use better message for consistency check (go-gitea#19672) Fix new release from tags list UI (go-gitea#19670) Update go deps (go-gitea#19665) [doctor] Add check/fix for bogus action rows (go-gitea#19656) [skip ci] Updated translations via Crowdin Add tooltip to pending PR comments (go-gitea#19662) Add Webfinger endpoint (go-gitea#19462) Update documentation to disable duration settings with -1 instead of 0 (go-gitea#19647) Set the LastModified header for raw files (go-gitea#18356) Don't select join table's columns (go-gitea#19660)
Although the use of LastModified dates for caching of git objects should be discouraged (as it is not native to git - and there are a LOT of ways this could be incorrect) - LastModified dates can be a helpful somewhat more human way of caching for simple cases. This PR adds this header and handles the If-Modified-Since header to the /raw/ routes. Fix go-gitea#18354 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Although the use of LastModified dates for caching of git objects should be
discouraged (as it is not native to git - and there are a LOT of ways this
could be incorrect) - LastModified dates can be a helpful somewhat more human
way of caching for simple cases.
This PR adds this header and handles the If-Modified-Since header to the /raw/
routes for branch, tag and commit.
Fix #18354
Signed-off-by: Andrew Thornton art27@cantab.net