I am trying to reload the page after a POST request is complete with this line:
window.location.reload();
On my local machine this is updating the content on the page, meanwhile on my remote server where I use Nginx I have to force refresh the page.
I tried:
window.location = window.location
window.location.href = window.location.href
window.location.reload(true);
//reloading with a setTimeout function
//turning off the cache in nginx
Your browser may be caching certain remote files (CSS, JS) by default. You could configure Nginx to always check for a new file if exists. 304 Not Modified is returned if file is not changed or 200 OK is returned with the new file.
## Force browser to check for new JS & CSS files
location ~ .(css|js)$ {
add_header Cache-Control no-cache;
etag on;
}
Also, browsers' reloading behavior can be affected if DevTools is open. Chrome provides the "Disable Cache" option for forcing new requests