views:

379

answers:

2

I am already using output caching in my ASP.NET MVC application.

Page speed tells me to specify HTTP cache expiration for css and images in the response header.

I know that the Response object contains some properties that control cache expiration. I know that these properties can be used to control HTTP caching for response that I am serving from my code:

Response.Expires
Response.ExpiresAbsolute
Response.CacheControl

or alternatively

Response.AddHeader("Expires", "Thu, 01 Dec 1994 16:00:00 GMT");

The question is how do I set the Expires header for resources that are served automatically, e.g. images, css and such?

A: 

Found it:

I need to specify client cache for static content (in web.config).

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlCustom="public" 
      cacheControlMaxAge="12:00:00" cacheControlMode="UseMaxAge" />
    </staticContent>
   </system.webServer>
</configuration>

from http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache

Marek
A: 

Look at mini static content delivery project. :)

dario-g