I'm looking for a way to cache a page at both the client and the server while varying the server's output cache by a querystring parameter "Version".
With this tag:
<%@ OutputCache Duration="10" Location="Any" VaryByParam="none" %>
I get these headers:
HTTP/1.1 200 OK
Cache-Control: public
Content-Type: text/html; charset=utf-8
Expires: Wed, 03 Feb 2010 02:29:24 GMT
Last-Modified: Wed, 03 Feb 2010 02:29:14 GMT
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.21006
X-Powered-By: ASP.NET
Date: Wed, 03 Feb 2010 02:29:14 GMT
Content-Length: 2364
This does exactly what I want on the client side, but on the server side it doesn't vary by "Version".
Meanwhile, with this tag:
<%@ OutputCache Duration="10" Location="Any" VaryByParam="Version" %>
I get these headers:
HTTP/1.1 200 OK
Cache-Control: public, max-age=4
Content-Type: text/html; charset=utf-8
Expires: Wed, 03 Feb 2010 02:28:29 GMT
Last-Modified: Wed, 03 Feb 2010 02:28:19 GMT
Vary: *
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.21006
X-Powered-By: ASP.NET
Date: Wed, 03 Feb 2010 02:28:25 GMT
Content-Length: 2352
This does exactly what I want on the server side, but the "Vary: *" header forces the browser to reload the page on every request.
Is there any way to get caching on both the client and server side while varying by a parameter?
Found it:
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetOmitVaryStar(true);
}
More info here: http://support.microsoft.com/kb/836868
Supposedly this has been fixed for ASP.NET 4 beta 2 (see http://www.asp.net/learn/whitepapers/aspnet4/breaking-changes/#_TOC10) but it still seems broken as of VS 2010 RC.