mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
fix(files): cache the site's media for a year (#62980)
This commit is contained in:
@@ -55,7 +55,8 @@ Set HTTP metadata when uploading:
|
||||
`application/gzip`. Missing types default to `application/octet-stream`.
|
||||
- `Content-Disposition`: use `attachment; filename="..."` when a file should
|
||||
download rather than display inline.
|
||||
- `Cache-Control`: defaults to `public, max-age=3600` (one hour). Use
|
||||
- `Cache-Control`: defaults to `public, max-age=3600` (one hour), or a year
|
||||
(`immutable`) under `site/`, whose files never change in place. Use
|
||||
`public, max-age=31536000, immutable` for versioned/content-addressed files,
|
||||
and a short TTL or `no-store` for mutable pointers such as `latest.json`.
|
||||
|
||||
|
||||
@@ -77,7 +77,9 @@ export default {
|
||||
headers.set("Last-Modified", object.uploaded.toUTCString())
|
||||
headers.set("Accept-Ranges", "bytes")
|
||||
if (!headers.has("Content-Type")) headers.set("Content-Type", "application/octet-stream")
|
||||
if (!headers.has("Cache-Control")) headers.set("Cache-Control", "public, max-age=3600")
|
||||
// The site's media never changes in place: a changed file gets a new dated folder (services/site/MEDIA.md).
|
||||
if (!headers.has("Cache-Control"))
|
||||
headers.set("Cache-Control", key.startsWith("site/") ? "public, max-age=31536000, immutable" : "public, max-age=3600")
|
||||
|
||||
const modified = Math.floor(object.uploaded.getTime() / 1000) * 1000
|
||||
const ifMatch = request.headers.get("If-Match")
|
||||
|
||||
Reference in New Issue
Block a user