summaryrefslogtreecommitdiffstats
path: root/modules/httpcache
Commit message (Collapse)AuthorAgeFilesLines
* Set `X-Gitea-Debug` header once (#23361)Yarden Shoham2023-03-081-6/+6
| | | | | | | | | | | | | | | | | | | | Instead of adding it # Before On the raw commit page: ![image](https://user-images.githubusercontent.com/20454870/223470744-cdf11898-e023-4198-8c8b-c294e5d78b73.png) # After ![image](https://user-images.githubusercontent.com/20454870/223470596-af898d66-bd5b-4ddb-b220-ceb1f149bfec.png) Fixes #23308 --------- Signed-off-by: Yarden Shoham <hrsi88@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Add some comments for recent code (#22725)wxiaoguang2023-02-021-0/+2
| | | | | | When using the main branch, I found that some changed code didn't have comments. This PR adds some comments.
* Fix cache-control header clearing comment text when editing issue (#22604)Brecht Van Lommel2023-02-011-2/+2
| | | | | | | | | | | The `no-store` cache control added in #20432 is causing form input to be cleared unnecessarily on page reload. Instead use `max-age=0,private,must-revalidate` which avoids this. This was particularly a problem when typing a long comment for an issue and then for example changing the label. The page would be reloaded and lose the unsubmitted comment. Fixes #22603
* Implement FSFE REUSE for golang files (#21840)flynnnnnnnnnn2022-11-272-4/+2
| | | | | | | | | Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Add Cache-Control header to html and api responses, add no-transform (#20432)silverwind2022-07-231-5/+12
| | | | | | | | | | | | `no-transform` allegedly disables CloudFlare auto-minify and we did not set caching headers on html or api requests, which seems good to have regardless. Transformation is still allowed for asset requests. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Andrew Thornton <art27@cantab.net>
* Set the LastModified header for raw files (#18356)zeripath2022-05-091-2/+37
| | | | | | | | | | | | | | 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>
* format with gofumpt (#18184)65432022-01-201-2/+1
| | | | | | | | | | | * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
* Use a variable but a function for IsProd because of a slight performance ↵Lunny Xiao2021-10-201-1/+1
| | | | increment (#17368)
* Avatar refactor, move avatar code from `models` to `models.avatars`, remove ↵wxiaoguang2021-10-062-15/+32
| | | | | | | | | | | | | | | | duplicated code (#17123) Why this refactor The goal is to move most files from `models` package to `models.xxx` package. Many models depend on avatar model, so just move this first. And the existing logic is not clear, there are too many function like `AvatarLink`, `RelAvatarLink`, `SizedRelAvatarLink`, `SizedAvatarLink`, `MakeFinalAvatarURL`, `HashedAvatarLink`, etc. This refactor make everything clear: * user.AvatarLink() * user.AvatarLinkWithSize(size) * avatars.GenerateEmailAvatarFastLink(email, size) * avatars.GenerateEmailAvatarFinalLink(email, size) And many duplicated code are deleted in route handler, the handler and the model share the same avatar logic now.
* Add ETag header (#15370)KN4CK3R2021-04-122-9/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | * Add ETag header. * Comply with RFC 7232. * Moved logic into httpcache.go * Changed name. * Lint * Implemented If-None-Match list. * Fixed missing header on * * Removed weak etag support. * Removed * support. * Added unit test. * Lint Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Use IsProd instead of testing if it's equal. (#14336)Lunny Xiao2021-01-141-1/+1
| | | | Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
* HTTP cache rework and enable caching for storage assets (#13569)silverwind2020-11-171-0/+59
This enabled HTTP time-based cache for storage assets, primarily avatars. I have not observed If-Modified-Since from browsers during tests but I guess it's good to support regardless. It introduces a new generic httpcache module that can handle both time-based and etag-based caching. Additionally, manifest.json and robots.txt are now also cachable.