mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
cache-control (#423)
Change CACHE_MAX_AGE to CACHE_CONTROL in AWS and Cloudflare
This commit is contained in:
1
serverless/aws/.gitignore
vendored
1
serverless/aws/.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
dist
|
dist
|
||||||
|
node_modules
|
||||||
@@ -232,9 +232,9 @@ export const handlerRaw = async (
|
|||||||
data = tilePostprocess(data, header.tileType);
|
data = tilePostprocess(data, header.tileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
headers["Cache-Control"] = `public, max-age=${
|
headers["Cache-Control"] =
|
||||||
process.env.CACHE_MAX_AGE || 86400
|
process.env.CACHE_CONTROL || "public, max-age=86400";
|
||||||
}`;
|
|
||||||
headers.ETag = `"${createHash("sha256")
|
headers.ETag = `"${createHash("sha256")
|
||||||
.update(Buffer.from(data))
|
.update(Buffer.from(data))
|
||||||
.digest("hex")}"`;
|
.digest("hex")}"`;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ interface Env {
|
|||||||
// biome-ignore lint: config name
|
// biome-ignore lint: config name
|
||||||
BUCKET: R2Bucket;
|
BUCKET: R2Bucket;
|
||||||
// biome-ignore lint: config name
|
// biome-ignore lint: config name
|
||||||
CACHE_MAX_AGE?: number;
|
CACHE_CONTROL?: string;
|
||||||
// biome-ignore lint: config name
|
// biome-ignore lint: config name
|
||||||
PMTILES_PATH?: string;
|
PMTILES_PATH?: string;
|
||||||
// biome-ignore lint: config name
|
// biome-ignore lint: config name
|
||||||
@@ -134,8 +134,9 @@ export default {
|
|||||||
) => {
|
) => {
|
||||||
cacheableHeaders.set(
|
cacheableHeaders.set(
|
||||||
"Cache-Control",
|
"Cache-Control",
|
||||||
`max-age=${env.CACHE_MAX_AGE || 86400}`
|
env.CACHE_CONTROL || "public, max-age=86400"
|
||||||
);
|
);
|
||||||
|
|
||||||
const cacheable = new Response(body, {
|
const cacheable = new Response(body, {
|
||||||
headers: cacheableHeaders,
|
headers: cacheableHeaders,
|
||||||
status: status,
|
status: status,
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ r2_buckets = [
|
|||||||
|
|
||||||
[vars]
|
[vars]
|
||||||
# ALLOWED_ORIGINS = "http://localhost:8000"
|
# ALLOWED_ORIGINS = "http://localhost:8000"
|
||||||
# CACHE_MAX_AGE = 86400
|
# CACHE_CONTROL = "public, max-age=86400"
|
||||||
Reference in New Issue
Block a user