diff options
author | zeripath <art27@cantab.net> | 2022-05-09 16:54:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-09 17:54:51 +0200 |
commit | 9f5ddca57c38f566fb18c9add339fc9f5aeb25de (patch) | |
tree | e9cba2540901589f98410b7d3ad23078a7dff11b /routers/common | |
parent | e435283c0ffe437f35898f92dc5572c8df83163e (diff) | |
download | gitea-9f5ddca57c38f566fb18c9add339fc9f5aeb25de.tar.gz gitea-9f5ddca57c38f566fb18c9add339fc9f5aeb25de.zip |
Set the LastModified header for raw files (#18356)
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 #18354
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers/common')
-rw-r--r-- | routers/common/repo.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/routers/common/repo.go b/routers/common/repo.go index b0e14b63f5..d037e151f9 100644 --- a/routers/common/repo.go +++ b/routers/common/repo.go @@ -10,6 +10,7 @@ import ( "path" "path/filepath" "strings" + "time" "code.gitea.io/gitea/modules/charset" "code.gitea.io/gitea/modules/context" @@ -22,8 +23,8 @@ import ( ) // ServeBlob download a git.Blob -func ServeBlob(ctx *context.Context, blob *git.Blob) error { - if httpcache.HandleGenericETagCache(ctx.Req, ctx.Resp, `"`+blob.ID.String()+`"`) { +func ServeBlob(ctx *context.Context, blob *git.Blob, lastModified time.Time) error { + if httpcache.HandleGenericETagTimeCache(ctx.Req, ctx.Resp, `"`+blob.ID.String()+`"`, lastModified) { return nil } |