0

I have put my web site through Google's pagespeed test and it has told me to "Leverage browser caching".

I did some research into this and found that I need to enable the content expiration in IIS 6. I did this and set the content to expire every 30 days. I then put my web site through the pagespeed test again and it still came up with the "Leverage browser caching" recommendation.

I have also put the web site through http://web-sniffer.net to see whats coming back and it comes back with Cache-Control: private.

I then tried <%@ OutputCache Duration="30" VaryByParam="none" %> in the web form and now it's coming back with Cache-Control: public, max-age=30 which I guess is along the right lines but the google page speed test is still coming back with a list of resources (mostly images) on my web page that have no expiration.

I'm quite confused on this subject. I was under the impression that the web site would inherit from the IIS settings but this wasn't the case until I turned on the outputcache on the page. Is there a way I can get the web site to use the IIS settings or has it got to be done on a page-by-page basis?

Curtis
  • 101,612
  • 66
  • 270
  • 352
tmutton
  • 1,091
  • 7
  • 19
  • 42
  • You can configure IIS to cache your CSS, JS and images. [See here.][1] [1]: http://stackoverflow.com/questions/7541032/caching-specific-javascript-and-css-files/7542816#7542816 – Icarus Oct 18 '11 at 17:45

2 Answers2

0

Pagespeed probably refers to static resources like js, css, png, gif, etc. files. By default IIS content expiration do not apply to those files. You need to edit IIS metabase manually.

http://www.galcho.com/Blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx

Jakub Konecki
  • 45,581
  • 7
  • 87
  • 126
0

Try adding the following to the code-behind in your form:

Response.Cache.SetCacheability(HttpCacheability.Server);
Response.Cache.SetExpires(DateTime.Parse("6:00:00PM"));

http://msdn.microsoft.com/en-us/library/system.web.httpcachepolicy.aspx

HttpCacheability enumeration:

  1. NoCache
  2. Private
  3. Server
  4. ServerAndNoCache
  5. Public
  6. ServerAndPrivate

http://msdn.microsoft.com/en-us/library/system.web.httpcacheability.aspx

James Johnson
  • 45,496
  • 8
  • 73
  • 110