During a server migration a new nginx configuration was missing cache conrol directives. Hence, we ended up with a cached index.html which is very bad for our SPA that is not refreshed anymore if we deploy new code. We need the index.html to not be cached.
To configure Nginx to not reload a website from the cache when a client user hits the website, you can use the proxy_cache_bypass directive.
server {
root /var/www/public_html/react/build;
index index.html index.htm index.nginx-debian.html;
server_name myapp.com www.myapp.com;
location / {
try_files $uri /index.html;
proxy_cache my_cache;
proxy_cache_bypass $http_pragma;
proxy_cache_revalidate on;
proxy_cache_min_uses 3;
proxy_cache_valid 200 60m;
proxy_cache_valid 404 1m;
proxy_cache_valid any 0;
add_header Cache-Control "no-store, no-cache, must-revalidate";
add_header Cache-Control "max-age=31536000, public";
}
Top comments (0)