Add expires headers in iis is very Easy,but this cache all the static files. now i want only add expires headers to images,how can i do that? even i want cached specific file?
Asked
Active
Viewed 7,770 times
2 Answers
11
- put all your images in one folder
- enter the manager--> yoursite--> images folder (or specific file)
- right click--> HTTP HEADERs--> Set expire header/date ! --> APPLY/OK
-
Ta for that. I used this to configure different expires for different folders in the app. Only thing that works on IIS7. Also for IIS6 you can achieve the same with some metabase magic - http://blog.stevensanderson.com/2008/07/07/overriding-iis6-wildcard-maps-on-individual-directories/ – penderi Oct 12 '11 at 09:27
-
1Depending on the version of IIS, step 3 might be: double-click "Http Response Headers" --> click Add... --> Enter Expires in name and a future data (15 Apr 2020 20:00:00 GMT) in value --> OK – Graham Sep 10 '14 at 12:30
0
I've been searching for a simpler solution and I found this.
Keep your static content inside a folder (eg: css, js). Create a web.config
file inside that folder. Add these following lines. Here 7
is the number of days, change it as you desire.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
You are free to keep as many static content folder as you want, simply add this web.config
file. Hope this helps.

Saahithyan Vigneswaran
- 6,841
- 3
- 35
- 45