I'm not fully understanding how .NET MVC's HTTP caching works because it doesn't seem like it's actually retrieving cached resource files. I'm thinking I need to add some additional code somewhere...
First, let's take a look at how I've set up HTTP caching on static content (ie. 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 results in the images in my application to appear to be caching properly. When I look at the response headers for an image, I see this (removed 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'm seeing an ETag value which is good and my Expires is what it should be. Additionally, the Last-Modified date is in the past. I understand the Last-Modified date to be the date the server was last asked for that file.
Now let's look at 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 from when the bundle is 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 MVC cached file is missing the ETag for one. There is a Cache-Control value of "public" which wasn't present on the static content response header. Lastly, the Expires is 1 year after the Last-Modified date which is correct, but the Last-Modified date is always the same as the Date value. These response headers to me seem like what they'd be when a resource is requested from the server for the first time and cached, not when it's been subsequently requested and retrieved from cache.
Thanks in advance for any insight.
UPDATE: It actually seems to be caching in IE. The Last-Modified date on subsequent requests remains a value in the past. I'm not seeing this in FF or Chrome, though. I confirmed that in both of those browsers, I haven't disabled caching. What gives?