Skip to content

Commit

Permalink
🔧(frontend) load fresh content from index.html on every request
Browse files Browse the repository at this point in the history
Prevent caching the index.html file which should load fresh content on
every request, based on @manuhabitela suggestion.
  • Loading branch information
lebaudantoine committed Jul 15, 2024
1 parent 522c68d commit fc258d7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/frontend/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ server {

root /usr/share/nginx/html;

# Serve static files
# Serve static files with caching
location ~* \.(css|js|json|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}

# Serve other requests without caching
location / {
try_files $uri $uri/ /index.html;

# Add no-cache headers
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache"; # HTTP 1.0 header for backward compatibility
add_header Expires 0;
}

# Optionally, handle 404 errors by redirecting to index.html
error_page 404 =200 /index.html;

location ~* \.(css|js|json|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
}

0 comments on commit fc258d7

Please sign in to comment.