I donโt quite understand how .NET MVC HTTP caching works, because it doesnโt seem like it really extracts cached resource files. I think I need to add some additional code somewhere ...
First, let's see how I set up HTTP caching on static content (i.e. images). In my web.config, I have the following:
<system.webServer> <staticContent> <clientCache cacheControlMode="UseExpires" httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" /> </staticContent> </system.webServer>
This causes the images in my application to look like caching properly. When I look at the response headers for the image, I see this (deleted unnecessary headers):
Date:Thu, 27 Feb 2014 16:27:48 GMT ETag:"086f8d199a4ce1:0" Expires:Tue, 19 Jan 2038 03:14:07 GMT Last-Modified:Thu, 29 Aug 2013 09:26:20 GMT
I see the ETag value, which is good, and my Expires is what it should be. In addition, the date of the last modification in the past. I understand that the Date of Last Modification was the date of the last request for this file.
Now consider the response headers for a javascript file that has been optimized by MVC. As a reminder, this article states that "Bundles set the HTTP Expires header one year after the package was created."
Cache-Control:public Date:Thu, 27 Feb 2014 16:44:16 GMT Expires:Fri, 27 Feb 2015 16:44:16 GMT Last-Modified:Thu, 27 Feb 2014 16:44:16 GMT Vary:User-Agent
The response headers for the cached MVC file do not have an ETag for one. There is a Cache-Control value of "public" that was not in the response header of static content. Finally, it expires one year after the date of the last modification, which is correct, but the date of the last modification always matches the date of the date. These response headers seem to me what they would be when the resource is requested from the server for the first time and cached, and not when it is subsequently requested and retrieved from the cache.
Thanks in advance for your understanding.
UPDATE . Actually, this is similar to caching in IE. The date of the last modification of subsequent requests remains valuable in the past. However, I do not see this in FF or Chrome. I confirmed that in both of these browsers I did not disable caching. What gives?