Everything being re-requested in production

Which reminds me, I noticed on my production site that everything is being re-requested by the browser and the server is responding with 200’s for the CSS, JS, and SVG’s, and not making requests for anything else. And the CSS and JS does appear versioned:

Request headers:

GET /css/app-44dec4b6d6acbf354a131a523ee1c7ed.css?vsn=d HTTP/1.1
Host: my.server.com
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
Accept: text/css,*/*;q=0.1
Referer: http://my.server.com/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Cookie: _my_server_key=eEhPVGNEQlU2RG05Q0dwUm9VOFdEVkhFd3l0SE5IQW5YUUVIV054REhCaENSSUVDaU9RTGZjaU9RakpFNks1RnJPOTd5UTdRdTdHb0VlUFRUMDlycnc9PS0tRmwxODV0RytCZ1dLdUFzVnkrZFpNZz09##e6yaxmgB0QjT4F688B1Qf_kustc=

Response Headers:

HTTP/1.1 200 OK
Cache-Control: public, max-age=31536000
Content-Type: text/css
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5 # Yes I know, not my choice... I build the software, not the server
X-Powered-By: ARR/3.0
X-Powered-By: ASP.NET
Date: Thu, 14 Jul 2016 16:40:48 GMT
Content-Length: 45755

So it is responding with a max-age=31536000, yet the browser always keeps requesting it again…

And yet the browser is not re-requesting the font files (unsure about png’s, don’t have any as SVG has been smaller than our PNG’s so far so only been using SVG’s).

How are you initiating the page load? CMD/CTRL+R may not use the cache. The best way is to enter the URL of the page in the address bar and hit ENTER or even better is to follow the link on your website. The browser’s developer tools may be disabling the cache also so verify that.

Ctrl+R (which should bypass cache), F5 (which ‘should’ not), clicking in the URL bar and hitting enter all are not caching this. I’ve not really looked into it in detail yet beyond that but no fail it re-requests those and gets status code 200 back. Chrome’s "Disable Cache while devtools is open) checkbox is unchecked. If I go to other sites than many things are brought from the cache. I can PM you the public link to the deployed site (no advertising my place of work is allowed) but it is mostly an empty front-end unless you log in, however it would be sufficient to show the issue as the front-page has an app.js and an app.css and an SVG. I am still not convinced that IIS is not causing an issue somehow (I use nginx on my own servers and not ‘noticed’ such issues, though does not mean not happening there either).

Are you always hit the dame url?
GET /css/app-44dec4b6d6acbf354a131a523ee1c7ed.css?vsn=d HTTP/1.1 or this is some dynamic id?

Always the same, that is the most recent version of the file generated by mix phoenix.digest and has been a stable name since last release.

Did yo ever figure out what was going on here? I notice that Google Page Insights dings default Phoenix installs for not specifying a cache validator (it says to set a Last-Modified or an ETag header to enable cache validation for the assets compiled in the digest). It also says they should have a Vary: Accept-Encoding.

Have you eliminated any of these warnings?

1 Like

Just to throw it out there, I noticed that chrome/safari may show 200, but in another column it could say “read from disk”. I found that 200 doesn’t always mean that it’s uncached, sometimes it means that it never even contacted the server (it’s very cached). 304 means that it actually did ask the server and got not-modified. Not a front-end dev, so it was news to me.