Search

The ServerAndClient parameter with the OutputCache page directive does not cache on the client, without code by AndyAtBeckbury

Closed
as Fixed Help for as Fixed

0
0
Sign in
to vote
Type: Bug
ID: 254940
Opened: 1/31/2007 9:45:35 AM
Access Restriction: Public
0
Workaround(s)
0
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.
Details (expand)
Product Language
English

Version

.NET Framework 2.0
Operating System
Windows XP Professional
Operating System Language
English
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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Cache Test</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <p>
                <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/MyImage.jpg"
                    Width="500" /></p>
            <p>
                <asp:HyperLink ID="NextPage" runat="server" Text="Next Page" NavigateUrl="~/BlankPage.htm"></asp:HyperLink></p>
        </div>
    </form>
</body>
</html>
Actual Results
Client browser ALWAYS requests the ASPX page from the Web server.
Expected Results
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. [Details]

 

Sign in to post a comment.
Posted by Microsoft 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!
Posted by Microsoft 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!
Sign in to post a workaround.