0

Is it possible to get IIS 7 (Server 2008) to cache content by looking at the Expires and/or Cache Control headers of the content being returned ?

(I have an ASP.NET app that is serving image tiles. Their expiry varies depending on different parameters and I set the Expires and Cache Control headers to indicate this to the IIS server. It doesn't seem to care much)

1
  • Which version of IIS are you using?
    – squillman
    Mar 11, 2011 at 14:12

1 Answer 1

1

Cache-control and expiry headers are usually directives to the client, or intermediate devices, not to the server.

When you set these headers, you're telling IIS to inject them into the HTTP response stream, so that the client (or other downstream devices) can cache/expire/whatever them.

If the ASP.Net application doesn't have some sort of built in cache or doesn't use ASP.Net Output Caching (if not, why not?), you might be able to force caching using the new IIS 7 native output cache (Output Caching feature).

As long as the files are uniquely identified in the request in some way, you can set the 'vary by' parameters in order to cache the output in memory on a per-url basis.

3
  • I am actually using ASP.NET Output cache. But that was not what I was asking in this question. HTTP 1.1 (rfc2616) states that a "public" directive in the Cache-control header "Indicates that the response MAY be cached by any cache". So I was wondering if IIS 7 can do this.
    – BjartN
    Mar 16, 2011 at 5:46
  • OK, sure - no, in this context IIS isn't a client to itself, it's simply producing an output stream. Interesting idea though, you could probably write a cache module that read the headers and activated local in-memory caching based on that.
    – TristanK
    Mar 16, 2011 at 6:23
  • Actually, thinking more about it - if ASP.Net Output Cache is working, it's about as good as you could hope to get it - you're saying you specify the expiry time etc, so assuming ASP.Net isn't under memory pressure and hasn't flushed the cache, it'll cache it in memory for as long as it can. IIS native cache happens as part of the worker process address space, so you've a limited amount of space there. Using ARR or another load balancer, layered onto the application, would perform the function you're looking for.
    – TristanK
    Mar 17, 2011 at 4:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .