nginx caches JS for one hour, as follows
location ~ .*\.(js|css)?$ { expires 1h; }
OK, this is no problem. I want to refresh the cache temporarily. At worst, I can just add a suffix, for example:abc.js?v=123
Now that I have debugged online, I want to remove the suffix and restoreabc.js?v=123
toabc.js
, but it is still cached at this time. , how to break it?
Your rule above just adds an expiration rule to the header
Tell the browser that this thing expires in 1 hour
It’s not that nginx caches it
This cache refers to the cache of your browser (client, not nginx). Under normal circumstances,
Ctrl+R
forced refresh will remove the cache.Or clear your browser cache and it will be OK.
Don’t use a purge cleaning module?
grunt-rev
This way, nginx header settings will never expire.
Using fis, the best front-end solution in the Eastern Hemisphere, we have a dedicated set of solutions.
fis
http://labs.frickle.com/nginx_ngx_cache_purge/README
Visit 127.0.0.1/purge/abc.js to delete cached files.
Add the parameter --add-module=/path/to/ngx_cache_purge when configuring to add this third-party purge module.
Similar to
expires
max-age
e-tag
These header information are cache headers for front-end browsers. For example, if you just set expires for one hour, then the browser will not request the file again one hour after the request is completed. To communicate with the server, local cache files are used every time. Within this hour, only the browser clears the cache or disables the cache in the developer tools to communicate with the server. Otherwise, any changes to the file on the server within this hour will have no impact on the browser. .