eTag and many versions of page
I have an ASP .NET site with a custom server-side caching system which is a nightmare. I want to use eTags to replace this.
Many of the links in the site return different versions of a page depending on sessi开发者_StackOverflowon state for the user. An example - mypage.aspx?p=a will return different versions of mypage - equally valid, depending on session state. I'd like to cache all versions.
Without totally redesigning the navigation links, how can I do this? From what I've read, putting a different eTag on each as they are generated and served for the first time will just cause the last-generated version to be invalidated and dropped from the cache.
Thanks
PS could I use Response.Cache.VaryByHeaders["Content-Length"] = true and rely on each version being different in length?
PPS Stupid idea! What about adding a custom header with a version key to the response and use VaryByHeaders on that.
The problem you have with custom headers is unless the thing at the other end understands them, they won't be reciprocated. So sending custom headers to IE will just result in it ignoring them.
You can use Output Caching though. It's possible to create your own outputcacheprovider. That would let you mess with the cache based on your requirements.
See http://msdn.microsoft.com/en-us/library/hdxfb6cy(VS.90).aspx for details on Output Caching.
It would appear the outputcacheprovider is only .Net 4
精彩评论