page outputcache.... varyByCustom = "Browser"

N

Nalaka

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.

Thanks
Nalaka
 
S

Steven Cheng[MSFT]

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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>
===============

=========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.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



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
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top