Http expires headers in asp.net with web.config

I am trying to get YSlow to give me A in the "Add Header" section by setting the web.config file.

I looked around, and this is what I put on, based on the fact that there:

<staticContent> <clientCache httpExpires="15.00:00:00" cacheControlMode="UseExpires"/> </staticContent> </system.webServer> 

This is what I see in Firebug:

 Response Headers HTTP/1.1 200 OK Server: ASP.NET Development Server/10.0.0.0 Date: Sun, 28 Aug 2011 13:54:50 GMT X-AspNet-Version: 4.0.30319 Cache-Control: private Content-Type: image/jpeg Content-Length: 24255 Connection: Close Request Headersview source Host localhost:50715 User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0 Accept image/png,image/*;q=0.8,*/*;q=0.5 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip, deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection keep-alive Referer http://localhost:50715/MySite/SiteHome.html Pragma no-cache Cache-Control no-cache 

However, when I look at it in Firefox, Yslow still gives F on this, even after Crtl-F5

What am I missing?

Thank.

+22
caching
Aug 28 2018-11-18T00:
source share
3 answers

From the clientCache documentation

The value of the httpExpires attribute must be a fully formatted date and time that follows the specification in RFC 1123. For example: Fri, Jan 01, 2010 12:00:00 GMT

So, if you want to use the http expires headers for your static content, set it like this:

 <staticContent> <clientCache cacheControlMode="UseExpires" httpExpires="Sun, 1 Jan 2017 00:00:00 UTC" /> </staticContent> 

Update (to the comments above): this will most likely still not work on the built-in VS server. I am not sure if it supports the end of headings. AFAIK is an IIS setup.

+15
Aug 28 '11 at 15:44
source

From the .NET Daily , I successfully applied this to a PHP site in IIS. It sets a maximum age of 30 days, instead of specifying an explicit date.

Add this to your web.config file:

 <system.webServer> <staticContent> <clientCache cacheControlMaxAge="30.00:00:00" cacheControlMode="UseMaxAge"/> </staticContent> </system.webServer> 

This configuration satisfies both the Browser Dock and End Headers cache caches. YSlow requires a value greater than 7 days. PageSpeed ​​is required from 30 days to 1 year.

+27
Jun 30 '14 at 5:28
source

I believe the recommendation is to add expiration to static content, not to ASPX pages. Make sure you check request headers for static content such as images, not an ASPX file.

Departure:

http://developer.yahoo.com/performance/rules.html

+2
Aug 28 2018-11-21T00:
source



All Articles