Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

How do I force IIS 7 to not cache images on a certain page?

share|improve this question

I don't think the IIS web server is the one caching pages - it's the client's browser.

You can add a meta tag to the pages you don't want the client side to cache, and there are ways to do this for different older browsers and such.

If you write in ASP and want the same non-cache effect, here's the header information.

<% Response.CacheControl = "no-cache" %>>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>
share|improve this answer
Those Response directives will only set the headers for ASP pages, not for static images. IIS settings need to be adjusted for static images. – Chris W. Rea Dec 19 '09 at 0:18

The thing you are looking for is cache-control header value (note that this only works for browsers that respect http 1.1)

For asp the code is:

<% @Language="VBScript" %>
<% Response.CacheControl = "no-cache" %>

You can also set this directly on a folder using the metabase:

Here's how you would set the folder pix on the default website: Open a command prompt and change to your C:\InetPub\AdminScripts folder. Run the following command: CSCRIPT ADSUTIL.VBS SET W3SVC/1/ROOT/pix/CacheControlCustom "no-cache"

Note the possible values are "no-cache" , "Public", "Private"

Yo can also set this via ADSI:

Option Explicit
Dim objCache
Set objCache = GetObject("IIS://localhost/w3svc/1/root/pix")
objCache.CacheControlCustom = "no-cache"

So far these approaches will work on IIS6 and IIS7 so long as you have the IIS6 admin tools installed. For a pure IIS7 environment here are the appcmd commands:

First unlock the config section

appcmd unlock config /section:staticContent

Now you're good to change the caching options for static content. Make static content non-cacheable by setting "Cache-Control: no-cache":

appcmd set config "Default Web Site/<Application>/<Folder>" /section:staticContent /clientCache.cacheControlMode:DisableCache

Where <Application>/<Folder> is the path to your folder

See also IIS 7.0: clientCache Element for staticContent (IIS Settings Schema)

share|improve this answer

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.