Preventing IIS from Caching .swf Files
Do you work with Micromedia Flash (.swf) files? Learn how to prevent IIS from caching these and other files that need to update frequently.
June 5, 2000
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:
Create a folder under your wwwroot folder named Flash.
Open the Internet Service Manager (ISM) in Windows 2000 or the IIS snap-in in the Microsoft Management Console (MMC).
Locate the Flash folder under your default Web site.
Right-click the Flash folder and select Properties.
Click the HTTP Headers tab.
Click Add in the Custom HTTP Headers section.
Add a header named Cache-Control with a value of no-cache.
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.
About the Author
You May Also Like