Library code snippets

Preventing Image Caching

Caching is a great way to improve performance on the Web;
however, sometimes you might want to force images to be
downloaded on each and every visit to a Web page. An example
of this might be a page that generates images dynamically
(for example, bar charts) but where the page uses the same
filenames over and over. Obviously, in this case, you must
require that the image be downloaded every time. So, to
prevent images in a directory from being cached, launch the
Internet Services Manager, navigate to the images directory in
question, then right-click the folder, and choose Properties.
In the Properties dialog box, select HTTP Headers, and then
click Add. Enter the following three headers:

cache-control:no-cache
pragma:no-cache
expires:0

This will prevent any images in the folder from being cached
on the client, so that you can modify them as often as you
like without fear of users seeing out-of-date versions.

Comments

  1. 17 Nov 2003 at 23:04

    Works perfectly with Internet Explorer but not with the Mozilla Firebird browser which continues to cache the page etc.....


    Does anyone know how to stop Firebird caching the page?

  2. 06 Aug 2003 at 10:53

    Ok - this doesn't work . What am I doing wrong . I added the custom headers and nothing happens.


    edit---
    Sorry, this worked fine. I was messing up...

  3. 14 Jan 2003 at 17:18

    Why when I edit the http headers in IIS do the settings disappear when I restart the server?

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Preventing Image Caching.

Leave a comment

Sign in or Join us (it's free).

AddThis

Related discussion

Related podcasts

  • ASP.NET Caching and Performance

    Steve Smith, owner of ASP Alliance and Lake Quincy Media joins us today to teach us about some hidden gems in ASP.NET caching and performance. Steve’s expertise in this area comes from first-hand experience as Lake Quincy’s ad system serves over 60 requests per second and handles over 150 million...

Related jobs