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()
|
||||
|
||||
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("X-Content-Type-Options", "nosniff")
|
||||
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)
|
||||
- complete no javascript support
|
||||
|
||||
|
||||
# roadmap/todo
|
||||
|
||||
- [x] upload endpoint
|
||||
- [x] content endpoint
|
||||
- [ ] update last accessed at
|
||||
- use a memory cache and batch commit to database to keep performance
|
||||
- [ ] 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
|
||||
- [ ] update last accessed at
|
||||
- use a memory cache and batch commit to database to keep performance
|
||||
- [x] add cache control headers
|
||||
|
||||
- [x] delete content endpoints
|
||||
- [ ] paste page
|
||||
- [ ] return a page for nojs clients, such as on delete or upload
|
||||
@@ -33,10 +32,13 @@ goals:
|
||||
- [ ] prometheus metrics
|
||||
- [x] [switch mime type detection library](https://git.whoswhip.dev/whoswhip/minibin/src/commit/47518993577f94d7cf9c0743042d2ac133055924/handlers.go#L273-L276)
|
||||
- [ ] ratelimits
|
||||
- [ ] simplify rendering & serving pages (too much duplicate code rn)
|
||||
|
||||
## misc goals
|
||||
|
||||
- [x] link to this git repo on home 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)
|
||||
- [ ] 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>
|
||||
<ul>
|
||||
<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>copyright infringing material</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user