Files
SkinbaseNova/deploy/nginx/static-cache.conf

41 lines
1.6 KiB
Plaintext

# -----------------------------------------------------------------------
# Long-term caching for static assets
#
# Include this file inside the relevant server {} block, e.g.:
#
# server {
# ...
# include /etc/nginx/conf.d/static-cache.conf;
# }
#
# Also apply equivalent rules on the cdn.skinbase.org server/bucket so
# that artwork thumbnails and avatars are cached for at least 1 year.
# For Contabo object storage, set the Cache-Control metadata on each
# object: Cache-Control: public, max-age=31536000, immutable
# -----------------------------------------------------------------------
# Vite build output — always content-hashed, safe to cache for 1 year.
location ~* ^/build/assets/.+\.(js|css|woff2?|ttf|otf|eot|svg|png|jpg|jpeg|webp|avif|ico|gif)$ {
add_header Cache-Control "public, max-age=31536000, immutable";
add_header Vary "Accept-Encoding";
access_log off;
try_files $uri =404;
}
# CDN user-content (artworks, avatars) — content-addressed by hash.
# Apply this block on the cdn.skinbase.org nginx server.
location ~* ^/(artworks|avatars|worlds/media)/.+\.(webp|avif|jpg|jpeg|png|gif|svg)$ {
add_header Cache-Control "public, max-age=31536000, immutable";
add_header Vary "Accept-Encoding";
access_log off;
try_files $uri =404;
}
# Public static images (logos, defaults) — not content-addressed, 7-day TTL.
location ~* ^/images/.+\.(webp|avif|jpg|jpeg|png|gif|svg|ico)$ {
add_header Cache-Control "public, max-age=604800, stale-while-revalidate=86400";
add_header Vary "Accept-Encoding";
access_log off;
try_files $uri =404;
}