Only send caching headers for existing objects (response code equals 200, 201, 204, 206, 301, 302, 303, 304, 307 or 308)

This commit is contained in:
Pim van Pelt
2025-09-05 12:05:07 +02:00
parent 425b485f5f
commit b646bca642

View File

@@ -23,48 +23,48 @@ const nginxTemplate = `server {
location = / {
try_files /index.html =404;
add_header Content-Type "text/html; charset=utf-8" always;
add_header Access-Control-Allow-Origin "*" always;
add_header Content-Type "text/html; charset=utf-8";
add_header Access-Control-Allow-Origin "*";
}
# Checkpoint endpoint - no caching
location = /checkpoint {
try_files /checkpoint =404;
add_header Content-Type "text/plain; charset=utf-8" always;
add_header Access-Control-Allow-Origin "*" always;
add_header Cache-Control "no-store" always;
add_header Content-Type "text/plain; charset=utf-8";
add_header Access-Control-Allow-Origin "*";
add_header Cache-Control "no-store";
}
# Log info endpoint
location = /log.v3.json {
try_files /log.v3.json =404;
add_header Content-Type "application/json" always;
add_header Access-Control-Allow-Origin "*" always;
add_header Cache-Control "public, max-age=3600, immutable" always;
add_header Content-Type "application/json";
add_header Access-Control-Allow-Origin "*";
add_header Cache-Control "public, max-age=3600, immutable";
}
# Issuer certificate endpoint - long cache
location ~ ^/issuer/(.+)$ {
try_files /issuer/$1 =404;
add_header Content-Type "application/pkix-cert" always;
add_header Access-Control-Allow-Origin "*" always;
add_header Cache-Control "public, max-age=604800, immutable" always;
add_header Content-Type "application/pkix-cert";
add_header Access-Control-Allow-Origin "*";
add_header Cache-Control "public, max-age=604800, immutable";
}
# Tile data endpoint - long cache, may have gzip
location ~ ^/tile/(.+)$ {
try_files /tile/$1 =404;
add_header Content-Type "application/octet-stream" always;
add_header Access-Control-Allow-Origin "*" always;
add_header Cache-Control "public, max-age=604800, immutable" always;
add_header Content-Type "application/octet-stream";
add_header Access-Control-Allow-Origin "*";
add_header Cache-Control "public, max-age=604800, immutable";
# Gzip encoding for .gz files
location ~ \.gz$ {
add_header Content-Encoding "gzip" always;
add_header Content-Encoding "gzip";
}
}
}