Clear Client Browser Cache with IIS

So you’ve updated your site and now you realise that some clients can’t see the changes of images/css because they all retain the same names as the old version?

Well in IIS you can change the Content Expiry Header to force the client to get the latest versions of the files.

For IIS 7 follow the step from Microsoft.

  1. In Features View in IIS, double-click HTTP Response Headers.
  2. On the HTTP Response Headers page, in the Actions pane, click Set Common Headers.
  3. In the Set Common HTTP Response Headers dialog box, select the Expire Web content check box and select one of the following options:
    • Select Immediately if you want content to expire immediately after it is sent in a response.
    • Select After if you want the content to expire periodically. Then, in the corresponding boxes, type an integer and select a time interval at which content expires. For example, type 1 and select Days if you want the content to expire daily.
    • Select On (in Coordinated Universal Time (UTC)) if you want the content to expire on a specific day and at a specific time. Then, in the corresponding boxes, select a date and time at which the content expires.

For IIS 6:

  1.  In IIS Manager, double-click the local computer; right-click the Web Sites folder, an individual Web site folder, a virtual directory, or a file; and then click Properties.
  2. Click the HTTP Headers tab.
  3. Select the Enable content expiration check box.
  4. Click Expire immediately, Expire after, or Expire on, and type the appropriate expiration information in the corresponding boxes.

Clearing the cache with Query String

If you have access to the source code mall modern browsers will treat resources such as a CSS, Javascript as new versions if you append a query string to them which is unique.


The actual content of the query string doesn’t matter as long as it’s unique, however most developers will tend to use v for version and then just set it to be the build number.

8 thoughts on “Clear Client Browser Cache with IIS

  1. You can also append a querystring, say…. site.css?v=129 if you don’t have access to IIS

    • Excellent point, I had to use my method when I didn’t know what was wrong with some closed source app running on an IIS server.

  2. What it mean to Select Immediately in the Expire Web content?
    Is that mean no user will have cash anymore as long as this selected?, if so it is no a good solution as it will be slow to users that all the time will load everything, and if I remove the selection, and users who didn’t use the web client during the time this option been selected will still have same issue if they open later after we remove the selection.

  3. Yosef

    you can use the On (in Coordinated Universal Time (UTC))

  4. How can I remove if I added this to my IIS? I added to the top level but i do not see it to remove it. My website is slow

    Thank you

    • Hi Grace,

      Instead of where you set the expires header content to say 1 day, set it to 30. Then that makes it so the caches expire after 30 days, which should then stop users redownloading all the cachable content every day.

  5. Will this clear the cache with the next request of the page? I tested this out and was unable to get my cached page to refresh from the server. Any thoughts?

    • It should do yes, if you check my post again I’ve added some extra content about how to use Query Strings to force the browser to get the latest version of CSS/JS.

Leave a Reply

Your email address will not be published. Required fields are marked *