What is the best approach to caching images in asp.net?
+3
A:
Where do you want to cache them?
If you want users/proxies to cache your site's images, the best way to do that would be to set up the caching in IIS on the folders containing your static content (images/JS/css), with suitable cache-busting strategies in place to ensure that if you do update them the calling clients get the latest versions.
In IIS 6 and below, you can do this by:
- Open IIS Manager.
- Expand the websites until you find your site, and the folder containing your images.
- Right click on the folder and select properties.
- Select the HTTP Headers tab.
- Check "Enable content expiration", and set the cache time in the "Expire after" section.
- Ok out of all the dialogues.
In IIS 7 you can do this by:
- Open IIS Manager.
- Expand the websites until you find your site, and the folder containing your images.
- Click on the folder in the section headed "IIS" double click on "HTTP Response Headers".
- Click on "Set Common Headers..." in the "Actions" pane.
- Check "Expire Web content", and set the cache time in the "After" section.
- Ok out of all the dialogues.
Zhaph - Ben Duguid
2009-12-03 16:05:11
Thanks Zhaph. it works great
Pragnesh Patel
2009-12-07 09:39:31
No problem, glad to help.
Zhaph - Ben Duguid
2009-12-07 09:49:37