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 this configuration for all static content on the site in the root directory:

<configuration>
<system.webServer>
   <staticContent>
     <clientCache cacheControlCustom="public"    cacheControlMode="UseExpires"
        httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" />
  </staticContent>
</system.webServer>
</configuration>

Now I want to give a different expires header to a specific file in a subdirectory and to the favicon file in the root directory. I'm trying this configuration after the above code but I get a server error.

<location path="">
<system.webServer>
  <staticContent>
     <clientCache cacheControlCustom="public"    cacheControlMode="UseExpires"
        httpExpires="Tue, 19 Jan 2012 03:14:07 GMT" />
  </staticContent>
  </system.webServer>
</location>

Maybe can anyone help?

share|improve this question
add comment

1 Answer

I don't think you can control the cache headers on a file level, only on a folder level. But you can always place the favicon in it's own folder and then you can control the cache control headers. If you want to support older browsers that always read the favicon from the root you can add a rewrite rule to rewrite the request to the specific folder.

To add the cache control headers on a per folder level you don't add the <location> tag but simply put a web.config file with the cache control tags in that specific folder.

share|improve this answer
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.