Reputation:
What got me started on this line of thought was when I played around with PageSpeed Insights and saw this message:
I have looked on the available forum posts and have tried this:
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
</system.webServer>
Looks simple, but when I verified both on my local server and my remote server, I saw no evidence that the cache setting stuck by means of Chrome Developer Tools.
After more research, I saw that the better way to do this was from within IIS. However, when I talked with GoDaddy technical support, they said that IIS was locked down to people like me because IIS changes affect everyone. So the IIS option is not an option for me.
However, if it was only a matter of the server, then wouldn't I see the web.config approach work on the local Visual Studio server? Clearly I'm missing something.
Am I doing this completely wrong or is it a matter of adding an extra line?
I'm starting to think that because web.config isn't doing the job and GoDaddy won't make any IIS changes, could something in Global.asax do the job? [And no, I can't tell my client to change servers.]
Upvotes: 3
Views: 1827
Reputation: 2895
Sometimes the mime types can be a bit of a pain when dealing with IIS caching. The code below gives you a basic example of how to ensure that your mappings are correct. You shouldnt need to do this for every mime type, only certain ones...
<staticContent>
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="text/javascript; charset=UTF-8" />
<!-- Caching-->
<clientCache cacheControlMode="UseExpires"
httpExpires="Tue, 22 Aug 2016 03:14:07 GMT" />
</staticContent>
Does the above code cache your JavaScript files correctly?
Also, have you tried recycling your App pool? Sometimes the server might need to be recycled before the changes kick in.
Upvotes: 2