Recenty a vue single page application project went live and it came to my attention that while some of us force-refresh the browser sometimes, the unexperienced user doesn't.
I've currently applied the following nginx conf to try and avoid cache of any kind but the browser still caches the information unless a force refresh is made.
Previously there was another segment to not apply cache on js and css files, so I've placed it within the server bracket to apply to everything (If I'm thinking correctly?)
The end result is: whenever a release is made (npm run build), I want the users to be able to see the new build result and not the one the browser is caching.
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /var/www/app/dist;
if_modified_since off;
expires off;
etag off;
add_header Cache-Control "private, no-cache";
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.+)$ /index.html last;
}
}