Visual Studio and .NET Framework Home
The ServerAndClient parameter with the OutputCache page directive does not cache on the client, without code
1/31/2007 9:45:35 AM
User(s) can reproduce this bug
In an ASPX page, if you declare <%@ OutputCache Location="Client" Duration="60" VaryByParam="None"%>, the page is correctly cached on the client.
If you wish to cache on the client AND the server, you can set <%@ OutputCache Location="ServerAndClient" Duration="60" VaryByParam="None"%>. However this time the "Vary: *" HTTP header is returned to the browser, which invalidates all client caching.
It is possible to prevent this, by programmatically adding Response.Cache.SetOmitVaryStar(true); into the Page_Load method, but it would be desirable for the "Vary: *" header not to be emitted by default as you are asking for the page to be cached on the client. The requested behaviour of the Location="ServerAndClient" attribute is being overriden by the inclusion of the "Vary: *" header.
It would be nice to either have the "Vary: *" header ommitted by default, or there being the ability to declaratively set the SetOmitVaryStar parameter through the outputCacheProfiles element in web.config.
.NET Framework 2.0
Windows XP Professional
Operating System Language
Steps to Reproduce
Create a simple ASPX page (ASP.NET 2.0, VS2005) with an ASP:Image server control and a HyperLink control. Configure TcpTrace or an equivalent to monitor the HTTP traffic between the browser and the IIS Web server.
Visit the page. Page is requested from the server, and server returns Vary: * in the response headers. Keep visiting the page, and it is always requested from the server.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ OutputCache Location="ServerAndClient" Duration="60" VaryByParam="None"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<form id="form1" runat="server">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/MyImage.jpg"
<asp:HyperLink ID="NextPage" runat="server" Text="Next Page" NavigateUrl="~/BlankPage.htm"></asp:HyperLink></p>
Client browser ALWAYS requests the ASPX page from the Web server.
Client browser requests the ASPX page from the Web server the first time, and when the cache is invalidated, as is seen with the Location="Client" attribute. All other times the local cache version is retrieved.
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 9/12/2008 at 10:17 AM
The next major version of the .NET Framework will no longer emit the "Vary:*" header when the @OutputCache directive's Location attribute is set to ServerAndClient.
Thank you for using Connect!
on 2/12/2007 at 6:13 PM
Since there is currently a workaround, we need to defer fixes for this issue until a future major release. However we will document the workaround in a Knowledge Base article.
Thank you for submitting this bug!
to post a workaround.
Please enter a workaround.
© 2014 Microsoft