Skip to content

Commit ea0b101

Browse files
fix(nginx): stop caching /public static files as 1y immutable
Split the asset cache rule into two locations applied to both the main and python.anyplot.ai server blocks: - /assets/* (Vite-fingerprinted) keeps expires 1y + immutable — safe because the filename changes on every build - stable-named files from /public (favicon.svg, logo.svg, og-image.png, fonts) drop immutable and get max-age=604800 (1 week), so content updates actually propagate instead of sitting behind a 1-year CDN lease Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1d46297 commit ea0b101

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

app/nginx.conf

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,19 @@ server {
4949
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
5050
gzip_static on;
5151

52-
# Cache static assets
53-
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
52+
# Vite-fingerprinted assets — filename changes on every build, safe to cache forever
53+
location ^~ /assets/ {
5454
expires 1y;
5555
add_header Cache-Control "public, immutable";
5656
}
5757

58+
# Stable-named static assets from /public (favicon.svg, logo.svg, og-image.png, fonts)
59+
# Short TTL so redeploys propagate within a week; revalidation allowed.
60+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
61+
expires 1w;
62+
add_header Cache-Control "public, max-age=604800";
63+
}
64+
5865
# Disable caching for index.html
5966
location = /index.html {
6067
add_header Cache-Control "no-cache, no-store, must-revalidate";
@@ -154,11 +161,19 @@ server {
154161
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
155162
gzip_static on;
156163

157-
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
164+
# Vite-fingerprinted assets — filename changes on every build, safe to cache forever
165+
location ^~ /assets/ {
158166
expires 1y;
159167
add_header Cache-Control "public, immutable";
160168
}
161169

170+
# Stable-named static assets from /public (favicon.svg, logo.svg, og-image.png, fonts)
171+
# Short TTL so redeploys propagate within a week; revalidation allowed.
172+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
173+
expires 1w;
174+
add_header Cache-Control "public, max-age=604800";
175+
}
176+
162177
location = /index.html {
163178
add_header Cache-Control "no-cache, no-store, must-revalidate";
164179
add_header Pragma "no-cache";

0 commit comments

Comments
 (0)