Skip to content

Commit 7c5eecb

Browse files
Adam GaborjaniAdam Gaborjani
authored andcommitted
fix: disable caching for config.js to ensure API keys update
1 parent 77a0f7f commit 7c5eecb

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

‎nginx.conf‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11
server {
22
listen 80;
33

4-
# Root directory for serving files
54
root /usr/share/nginx/html;
65
index index.html;
76

8-
# Gzip compression for speed
97
gzip on;
108
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
119

10+
# NEW: Do not cache the config file so keys can be updated instantly
11+
location = /config.js {
12+
expires -1;
13+
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
14+
}
15+
1216
location / {
13-
# First attempt to serve request as file, then
14-
# as directory, then fall back to redirecting to index.html
1517
try_files $uri $uri/ /index.html;
1618
}
1719

18-
# Cache static assets (JS/CSS) for 1 year
19-
location ~* \.(?:css|js|jpg|svg|buffer|png|ico|woff2)$ {
20+
# Cache other static assets (images, fonts, etc.)
21+
location ~* \.(?:jpg|jpeg|gif|png|ico|svg|woff|woff2|ttf|eot)$ {
22+
expires 1y;
23+
add_header Cache-Control "public";
24+
}
25+
26+
# Cache JS/CSS bundles (Vite adds hashes to these, so caching is safe)
27+
location ~* \.(?:css|js)$ {
28+
# But exclude config.js which we handled above
29+
if ($request_uri ~* "config\.js") {
30+
return 404; # Should not happen due to the = /config.js block above
31+
}
2032
expires 1y;
2133
add_header Cache-Control "public";
2234
}
@@ -25,4 +37,4 @@ server {
2537
location = /50x.html {
2638
root /usr/share/nginx/html;
2739
}
28-
}
40+
}

0 commit comments

Comments
 (0)