Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have to set expiration for my static files of my application in IIS 7. Using the dialog below: I set it to 10 days.

enter image description here

But when I look at my page analysis using PageSpeed add-on in Chrome, I see that there is no expiration on the files.

enter image description here

Do I have to do something else in my application's configuration too?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Check out the staticContent element of web.config:

  <system.webServer>
    <!-- StaticContent requires that the machine config section be unlocked: appcmd unlock config /section:staticContent-->
    <staticContent>
      <clientCache cacheControlCustom="private" cacheControlMode="UseMaxAge" cacheControlMaxAge="0.02:00:00" />
    </staticContent>
  </system.webServer>

http://msdn.microsoft.com/en-us/library/ms689506%28v=vs.90%29.aspx

http://www.iis.net/configreference/system.webserver/staticcontent/mimemap

share|improve this answer
    
I add the part you suggested but nothing changes. (it says "expiration not specified" for the two .js files in my Data folder.) –  anilca Nov 26 '12 at 15:10
1  
I've verified that this does indeed work. Did you unlock the machine.config section? –  Greg Askew Nov 26 '12 at 18:25
    
Ooh! I missed the unlocking part. You're right, it works like a charm! Thanks for your help. –  anilca Nov 27 '12 at 6:50
add comment

This setting in IIS controls the expiration of the page returned and not the other resources that the page includes and attempts to load, in your case external JS files. If you check the expiration tag for the page it should show an expiration date.

The IIS setting you are looking at will not control the expiration of other files that are not directly part of the response stream. With JS files why are you trying to expire them after 10 days anyway? The browser should recognize that they are no longer the current version and will download the latest, otherwise it will show a HTTP 304 Not Modified and will use the locally cached copy.

share|improve this answer
    
So why do the pagespeed suggests me to do that as you see in the second image? I think I'm not understanding the concept. –  anilca Nov 26 '12 at 14:56
    
I would worry less about caching your JS files as most modern browsers do that anyway, instead you should look into minifying and consolidating your JS files which would provide more speed benefits over local caching. –  Brent Pabst Nov 26 '12 at 15:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.