page outputcache.... varyByCustom = "Browser"

Discussion in 'ASP .Net' started by Nalaka, Oct 13, 2006.

  1. Nalaka

    Nalaka Guest

    I had .....
    <%@ OutputCache Duration="5000" Location="Server" VaryByParam="none" %>

    Then I added "browser"
    <%@ OutputCache Duration="5000" Location="Server" VaryByParam="none"
    VaryByCustom="browser" %>

    After I added browser... it stopped caching pages....
    is there an explanation or... did I observe the problem wrong?

    Hosting company probbably have many more on the same machine.. is there a
    chance that cacching will not work, if there are memory constraints.

    Nalaka, Oct 13, 2006
    1. Advertisements

  2. Hello Nalaka,

    As for the OutputCache of ASP.NET page, when you specify the
    "VaryByCustom=browser", that means the page's output content will be cached
    based on the client-side web request's browser header information(this is
    usually stored in useragent http header).

    And for your scenario, if you have the following cache setting in page:

    <%@ OutputCache Location="server" Duration="300" VaryByParam="none"
    VaryByCustom="browser" %>

    the page will be cached according to the two flag:

    ** duration="300"

    ** VaryByCustom="browser"

    So when you use IE to visit the page(no local or remote machine), the
    output result will be cached and only after 300 seconds will the cache be
    invalid. And if you use another browser(e.g firefox) to visit the page,
    the server-side will generate another cache versino of this page, and all
    seqential requests from other machine using firefox(same version) will will
    get the same cached output (until it expires after 300 seconds).

    I've tested this through the following test page:

    <%@ Page Language="C#" AutoEventWireup="true"
    CodeFile="OutputCachePage.aspx.cs" Inherits="Cache_OutputCachePage"
    <%@ OutputCache Location="server" Duration="300" VaryByParam="none"
    VaryByCustom="browser" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    <html xmlns="" >
    <head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">


    =========code behind=========
    public partial class Cache_OutputCachePage : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
    Response.Write("<br/>Datetime: " + DateTime.UtcNow.ToString());


    As for the "it stopped caching pages", what's the detailed behavior? Do you
    mean no matter you use different browser not not, it will always output new
    updated content each time you send reqeust to the page(refresh the browser)?

    Please feel free to let me know if you have anything unclear.


    Steven Cheng

    Microsoft MSDN Online Support Lead


    Get notification to my posts through email? Please refer to

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Oct 16, 2006
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bruce barker

    Re: OutputCache Back Button Page Expires

    bruce barker, Oct 20, 2004, in forum: ASP .Net
    bruce barker
    Oct 20, 2004
  2. =?Utf-8?B?QnJpYW5HZW5leA==?=

    Page Level OutputCache and IIS

    =?Utf-8?B?QnJpYW5HZW5leA==?=, Jan 27, 2005, in forum: ASP .Net
    Jan 27, 2005
  3. Sudhir Sharma

    OutputCache with Page not working propely

    Sudhir Sharma, Mar 25, 2005, in forum: ASP .Net
    Rick Strahl [MVP]
    Mar 27, 2005
  4. Frank Rizzo

    How to remove page from OutputCache

    Frank Rizzo, Feb 20, 2006, in forum: ASP .Net
    Frank Rizzo
    Feb 20, 2006
  5. Nalaka
    Steven Cheng[MSFT]
    Oct 12, 2006

Share This Page