Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 down vote accepted

Check out the staticContent element of web.config:

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

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
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

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

Your Answer


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.