1

Chrome will not cache the CSS files on my site, the js files are cached without issue, but the CSS is loaded from server every time. The server is IIS 8 and in my web.config I have:

  <location path="Content/dist">
<system.webServer>
  <staticContent>
    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:15" />
  </staticContent>
</system.webServer>

which sets the cache to expire in 1 day. in the header for my CSS files I can see that it has taken as there is this:

Cache-Control: max-age=86415

The full header is as follows:

Accept-Ranges: bytes
Cache-Control: max-age=86415
Content-Encoding: gzip
Content-Length: 78464
Content-Type: text/css
Date: Thu, 16 Aug 2018 11:46:30 GMT
ETag: "053689a4935d41:0"
Last-Modified: Thu, 16 Aug 2018 10:12:14 GMT
Server: Microsoft-IIS/8.5
Vary: Accept-Encoding
X-Powered-By: ASP.NET

On my local machine, the files are read from cache as expected, but when I push to the server I have the troubling behavior. Its just CSS that this is happening with, .js files from that same folder referenced in web.config are loading from cache. Here is the header from one such file.

Accept-Ranges: bytes
Cache-Control: max-age=86415
Content-Encoding: gzip
Content-Length: 3698
Content-Type: application/javascript
Date: Thu, 16 Aug 2018 11:45:44 GMT
ETag: "f7e1df9a4935d41:0"
Last-Modified: Thu, 16 Aug 2018 10:12:14 GMT
Server: Microsoft-IIS/8.5
Vary: Accept-Encoding
X-Powered-By: ASP.NET

Firefox loads the files from cache as I expect too.

https://gyazo.com/3ba41707c00e7fb539f6b84cc90f70e0

Site URL :

https://devworks.cashbackforex.com/

Kevin Bradshaw
  • 6,327
  • 13
  • 55
  • 78
  • Can you post the code for html file for which you added the screenshot. Looking at header in the file might help. – Dipen Shah Aug 20 '18 at 19:06
  • https://devworks.cashbackforex.com/ – Kevin Bradshaw Aug 21 '18 at 11:04
  • I think this could be because your site is untrusted try it on just a http url and see if you get the same result. – Daniaal Aug 21 '18 at 13:53
  • yep, spot on Daniaal, that did it. In fairness to kamalpreet below, he had suggested it was a cert issue too, but I hadnt followed up on it. I had thought I could split the bounty between 2, but apparently I cant. So Im kind of undecided as to who to award it.. – Kevin Bradshaw Aug 21 '18 at 14:04
  • Well whose post lead you to go and actually try to solve the problem? P.S I will also love you forever and you should help a newbie out ;) – Daniaal Aug 21 '18 at 21:46

1 Answers1

3

I faced similar kind of issue and turns out to be web.config's compilation attribute was set to debug=true, as-

<compilation debug="true"></compilation>

It causes your files to neither be bundled nor cached on browser. Just removing debug=true resolved my issue. So I changed it to-

<compilation></compilation>

Edit-

For Chrome specifically, it could be related to your certificate.

Chrome does not cache resources from servers with self-signed certificate.

See here

soccer7
  • 3,547
  • 3
  • 29
  • 50