I've been trying to configure server side caching for a WCF service hosted on IIS7, but I've been encountering some strange issues that appear to be either design flaws or bugs in IIS7's caching framework.
* The documentation for "duration" on a caching profile states that it's configured as "seconds", even though it's a timespan instance. If it was a TimeSpan, specifying duration="5" would mean 5 days, not 5 seconds. The documentation appears to be wrong. http://msdn.microsoft.com/en-us/library/ms691315.aspx
* The documentation states that the "location" value's default is "Any". However, when I view the HTTP response IIS7 has set cache-control to "no-cache". The documentation appears to be wrong. http://msdn.microsoft.com/en-us/library/ms691315.aspx
* There is no way to configure server side caching without also setting client-side headers! This is an extremely aggrivating frustration and I might be a design oversight. For example, setting <add extension=".svc" policy="CacheForTimePeriod" duration="12:00:00" /> results in a "Cache-Control: no-cache" header, which is not what I want. There doesn't appear to be any way to configure server side caching without affecting the cache-control header. For example, I may want to configure server side caching while leaving the client at it's "default" setting.
* The documentation for "varyByQueryString" is confusing. Does that mean that differing querystrings are treated as the same response by kernel mode caching? Shouldn't the default be to treat each canonical URL (including querystrings) as a unique response for caching, even in the kernel? It seems as though the correct behavior is the opposite - that all querystrings are "non-varied" unless specified otherwise. They are parameters that affect the response, after all. For example, product.aspx?product=1 is NOT the same as product.aspx?product=2.
Take an ASPX site as an example. How am I supposed to configure varyByQueryString? If I have 100 .ASPX pages and want to cache them, I would then create a "caching profile" for the .ASPX extension in the web.config. Each of those 100 ASPX files may have differnet querystrings - can you imagine having to configure hundreds of different querystring parameters in a single varyByQueryString attribute? What a nightmare.
* My application sets it's own "Cache-Control" header of "public,max-age=1209600". If I also configure IIS 7 server side caching, the returned response header appears as: "Cache-Control: no-cache,public,max-age=1209600". Definitely a bug! Again, IIS is mucking with my headers and not even doing it correctly.
* IIS 7 doesn't "transparently cache" based on what the application sets in it's cache-control header. For example, my application itself could determine what needs to be cached on a url-by-url basis. I'm already setting "Cache-Control: Public" as a response header. IIS7's server side cache is "upstream" from my generated response, so if caching was enabled it seems to me it should just gracefully cache as the default behavior. For example, I might be programming an ASP.NET MVC website - there are no extensions to configure since it uses application routing. That makes using IIS7 caching next to impossible.
Help! I really need server side caching for performance, but I'm not sure how to make it behave properly and stop messing with my client side headers.