diff options
| author | soruly <[email protected]> | 2020-08-09 15:57:23 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-08-09 15:57:23 +0800 |
| commit | 0c040629726ac8cc77f13a091c2fc6ccb743c3da (patch) | |
| tree | 5dc2d453a5be572d58a9719eda0d9937421ae09a | |
| parent | Update CORS header (diff) | |
| download | trace.moe-image-proxy-0c040629726ac8cc77f13a091c2fc6ccb743c3da.tar.xz trace.moe-image-proxy-0c040629726ac8cc77f13a091c2fc6ccb743c3da.zip | |
Increase cache duration
| -rw-r--r-- | api/image-proxy.ts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/api/image-proxy.ts b/api/image-proxy.ts index 5377d15..c16c22e 100644 --- a/api/image-proxy.ts +++ b/api/image-proxy.ts @@ -29,7 +29,7 @@ export default async (request: NowRequest, response: NowResponse) => { if (["image", "video"].includes(res.headers.get("Content-Type").split("/")[0].toLowerCase())) { response.setHeader("Content-Type", res.headers.get("Content-Type")); - response.setHeader("Cache-Control", "s-maxage=86400"); + response.setHeader("Cache-Control", "max-age=3600, s-maxage=86400, stale-while-revalidate"); } else if (res.headers.get("Content-Type").toLowerCase() === "application/octet-stream") { const match = imageURL.match(/\.(\w{3,4})($|\?)/); if (!match) return response.status(400).send("Error: Cannot determine Content-Type"); @@ -47,7 +47,7 @@ export default async (request: NowRequest, response: NowResponse) => { }[match[1]]; if (!contentType) return response.status(400).send("Error: Unknown Content-Type"); response.setHeader("Content-Type", contentType); - response.setHeader("Cache-Control", "s-maxage=86400"); + response.setHeader("Cache-Control", "max-age=3600, s-maxage=86400, stale-while-revalidate"); } else { return response.status(400).send("Error: Unsupported Content-Type"); } |