I have an issue where Chrome browsers do not reload updated javascripts.
This is because, in Chrome, the request is never sent to the server.
The other browsers I support (Firefox, Edge, Safari) work fine; this appears to be because they send an If-Modified-Since header.
The file is served as part of a collection of static assets. Everything is gzipped by nginx.
sites-available/default:
root /var/www;
index index.php index.html index.htm;
// some php stuff ...
A (maybe?) relevant line from /etc/nginx.conf
# Proxy cache
proxy_cache_path /var/tmp/nginxcache keys_zone=one:10m;
Curl output for a get on the javascript:
< HTTP/1.1 200 OK
* Server nginx/1.4.6 (Ubuntu) is not blacklisted
< Server: nginx/1.4.6 (Ubuntu)
< Date: Sun, 05 Aug 2018 11:52:44 GMT
< Content-Type: application/x-javascript
< Content-Length: 2350005
< Last-Modified: Sun, 05 Aug 2018 11:38:36 GMT
< Connection: keep-alive
< Vary: Accept-Encoding
< ETag: "5b66e1bc-23dbb5"
< Accept-Ranges: bytes
Is there a configuration in nginx that can persuade Chrome to do likewise? I have explored these answers: Setting expires headers for static content served from nginx and https://stackoverflow.com/questions/17251503/set-expires-to-max-for-all-images-of-all-servers-in-nginx/17253805#17253805 but my regex skills are rather poor, and the answers are quite old. Should I try:
location ~ \.js {
expires 1d;
add-header Pragma public
add-header Cache-control "public"
}