Preventing IIS from Caching .swf Files

Macromedia Flash (.swf) files are animated images with a very small footprint. These files are lightweight, and brilliant Web artists can do real magic with them. (Click here for some great examples.) When I saw Flash files for the first time, I was resistant to them because I assumed that they were huge animated files that soaked up valuable bandwidth. I was wrong.

I was working with some IIS administrators who had to solve a problem in which IIS appeared to be caching Flash images and thereby failing to render new updates when a visitor accessed the Web site. Our reaction was, of course, "That has to be a client-side problem." We asked the business owners questions such as, "Can you reproduce the problem?" and "Does it also happen in Netscape?" I did a little research on the Microsoft Developer Network (MSDN). I asked the program manager involved if she could move all the .swf files into their own folder on the Web site. She did, and we then forced IIS not to cache the .swf files on all the Web servers in the farm.

Here's a little background on how IIS caches files. You use MIME to configure browsers or mail clients to view files in many different formats. IIS uses MIME mapping to map files by extension to a particular MIME type. For example, a file with the extension .htm has a MIME type of "text/html," and a file with the extension .gif has a MIME type of "image/gif." When a browser makes a request for a particular file, IIS uses the MIME map to determine the correct MIME type; IIS then passes this information to the browser receiving the file. IIS contains a large list of default MIME types; if IIS hasn't explicitly mapped an extension, it returns a MIME type of "application/octet-stream."

The easiest way to disable caching for a given MIME type, such as .swf files, is to create a folder that will contain the files and then set custom headers for that folder. You can disable file caching in a Flash folder by following these steps:

  1. Create a folder under your wwwroot folder named Flash.
  2. Open the Internet Service Manager (ISM) in Windows 2000 or the IIS snap-in in the Microsoft Management Console (MMC).
  3. Locate the Flash folder under your default Web site.
  4. Right-click the Flash folder and select Properties.
  5. Click the HTTP Headers tab.
  6. Click Add in the Custom HTTP Headers section.
  7. Add a header named Cache-Control with a value of no-cache.
  8. Click OK.

After this change, IIS will no longer cache any files in this folder, which is especially useful when you work with images that frequently update.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.