cache control header on content endpoint
This commit is contained in:
@@ -310,6 +310,12 @@ func contentHandler(db *gorm.DB, cfg Config) http.HandlerFunc {
|
|||||||
|
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
ttl := 600 // 10 minutes
|
||||||
|
if upload.ExpiresAt != nil {
|
||||||
|
ttl = int(*upload.ExpiresAt - now)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d, must-revalidate", ttl))
|
||||||
w.Header().Set("Content-Type", upload.MIMEType)
|
w.Header().Set("Content-Type", upload.MIMEType)
|
||||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||||
http.ServeContent(w, r, upload.Filename, time.Unix(upload.CreatedAt, 0), file)
|
http.ServeContent(w, r, upload.Filename, time.Unix(upload.CreatedAt, 0), file)
|
||||||
|
|||||||
@@ -14,15 +14,14 @@ goals:
|
|||||||
- moderable (reports, mime type filtering, hash ban, etc)
|
- moderable (reports, mime type filtering, hash ban, etc)
|
||||||
- complete no javascript support
|
- complete no javascript support
|
||||||
|
|
||||||
|
|
||||||
# roadmap/todo
|
# roadmap/todo
|
||||||
|
|
||||||
- [x] upload endpoint
|
- [x] upload endpoint
|
||||||
- [x] content endpoint
|
- [x] content endpoint
|
||||||
- [ ] update last accessed at
|
- [ ] update last accessed at
|
||||||
- use a memory cache and batch commit to database to keep performance
|
- use a memory cache and batch commit to database to keep performance
|
||||||
- [ ] add cache control headers
|
- [x] add cache control headers
|
||||||
- [ ] add a config option to put the endpoint on another path, such as `/f/{id}`
|
|
||||||
- allowing more specific caching options through reverse proxies like cloudflare
|
|
||||||
- [x] delete content endpoints
|
- [x] delete content endpoints
|
||||||
- [ ] paste page
|
- [ ] paste page
|
||||||
- [ ] return a page for nojs clients, such as on delete or upload
|
- [ ] return a page for nojs clients, such as on delete or upload
|
||||||
@@ -33,10 +32,13 @@ goals:
|
|||||||
- [ ] prometheus metrics
|
- [ ] prometheus metrics
|
||||||
- [x] [switch mime type detection library](https://git.whoswhip.dev/whoswhip/minibin/src/commit/47518993577f94d7cf9c0743042d2ac133055924/handlers.go#L273-L276)
|
- [x] [switch mime type detection library](https://git.whoswhip.dev/whoswhip/minibin/src/commit/47518993577f94d7cf9c0743042d2ac133055924/handlers.go#L273-L276)
|
||||||
- [ ] ratelimits
|
- [ ] ratelimits
|
||||||
|
- [ ] simplify rendering & serving pages (too much duplicate code rn)
|
||||||
|
|
||||||
## misc goals
|
## misc goals
|
||||||
|
|
||||||
- [x] link to this git repo on home page
|
- [x] link to this git repo on home page
|
||||||
- [ ] maybe keep nojs and js on the same page?
|
- [ ] maybe keep nojs and js on the same page?
|
||||||
- just use javascript to enhance the experience, like progress, drag and drop
|
- just use javascript to enhance the experience, like progress, drag and drop
|
||||||
- [ ] shareX config download handlers (automatically create based off of config)
|
- [ ] shareX config download handlers (automatically create based off of config)
|
||||||
|
- [ ] add a config option to put the endpoint on another path, such as `/f/{id}`
|
||||||
|
- allowing more specific caching options through reverse proxies like cloudflare
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
<p>do not upload or share:</p>
|
<p>do not upload or share:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>child sexual abuse or exploitation material</li>
|
<li>child sexual abuse or exploitation material</li>
|
||||||
<li>malware, viruses, or file intended to harm other people</li>
|
<li>malware, viruses, or files intended to harm other people</li>
|
||||||
<li>extreme gore</li>
|
<li>extreme gore</li>
|
||||||
<li>copyright infringing material</li>
|
<li>copyright infringing material</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user