We help IT Professionals succeed at work.

IIS 6: Custom Caching Headers

hankknight asked
I want all images in a specific directory to be cached until 2020.  

I want these headers to be sent:

HTTP/1.1 200 OK 
X-Powered-By: XYZ Server 
Cache-Control: public 
Expires: Sun, 29 Mar 2020 00:00:00 GMT 
Content-Disposition: inline; 

Open in new window

I do NOT want these headers to be sent at all, but if the
must be sent, they must be blank:

Open in new window

This can be done with Apache using the following code.   Can it be done with IIS 6?

### .htaccess code for Apache --- Needs to be translated to work with Microsoft-IIS/6.0

<FilesMatch "\.(jpg|jpeg|png|gif|bmp)$">
Header unset ETag
FileETag None
Header set Cache-Control "public"
Header set Expires "Sun, 29 Mar 2020 00:00:00 GMT"
Header unset Last-Modified

Open in new window

Watch Question

Sr. Network / Systems Admin
First part, yes, you can set any custom headers in IIS 6 you want via the Properties > HTTP Headers tab.
To blank the others out, I believe you can simply create the custom header and not assign a value.  I'd have to test that, though.

To cache until a certain date, on the properties of your subdirectory you wish to cache, you can select the HTTP Headers once again, and "Enable content expiration", then select either "Expire after" or "Expire on", depending on which method fits what you are trying to do best.  The latter will allow you to set an explicit date, instead of a relative time.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.