HighTechTalks DotNet Forums  

How to set output page cache for all pages at once?

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss How to set output page cache for all pages at once? in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jason
 
Posts: n/a

Default How to set output page cache for all pages at once? - 05-24-2006 , 11:43 AM






Is there an easy way to set the output page cache for all pages in an app at
once?

It seems like the only way to set the page output cache is to use the
@OutputCache directive in each page, or to do it programatically. I've also
tried to do it programatically within a master page, but that doesn't seem to
work either.

Is there any way to do this globally for every page in an app?

Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default RE: How to set output page cache for all pages at once? - 05-25-2006 , 01:20 AM






Hi Jason,

Thank you for posting.

As for the OutputCache configuration you mentioned, I'm wondering whether
you're developing the application upon ASP.NET 1.x or ASP.NET 2.0. Based
on my research, ASP.NET 1.x only provide declarative or programmatic
interfaces for configuring outputCache, and declarative approach need us to
specify the outputCache setting in the @OutputCache directive in aspx
template.

In ASP.NET 2.0, there does provide new configuration setting in the
application config file(web.config or machine.config ). Those settings can
help define some global level cache profiles(somewhat like cache setting
template), and we can apply these template profile to any page in our web
application. You can get the detailed info in the following msdn reference:

#Cache Configuration in ASP.NET
http://msdn2.microsoft.com/en-us/library/ms178606.aspx

However, the above approach still require us to add the profile setting in
each individual aspx page like:

<%@ OutputCache CacheProfile="MyCacheProfile1" %>

So far there still lack a configuration setting which can directly put an
outputCache for all the pages in the application. If you do want to apply
OutputCache on all the pages or a certain group of pages in an ASP.NET
application, you can consider use code to programmatically set the Page
Response's Cache properties. e.g:

============================
void Application_BeginRequest(object sender, EventArgs e)
{

HttpContext.Current.Response.Cache.SetCacheability (HttpCacheability.Server);
...............
}
============================

The above code use the appliation's global class's "BeginRequest" event to
set the cache properties on the HttpResponse. Also, based on my research,
the @OutputCache directive used in aspx template actually is compiled as an
internal function which is called by the dynamic compiled page class in a
initialize function named "FrameworkInitialize()", we can use reflector to
check the dynamic generated page assembly to verify this. And If you would
like to programmatically configure the cache properties, you can reference
to the autogenerated code:

=====================
protected override void FrameworkInitialize()
{
this.StyleSheetTheme = "White";
base.FrameworkInitialize();
this.__BuildControlTree(this);

base.AddWrappedFileDependencies(outputcache_ocpage _aspx.__fileDependencies);

// this is the runtime generated code for initlizing caching
this.InitOutputCache(outputcache_ocpage_aspx.__out putCacheSettings);
base.Request.ValidateInput();
}
=========================


Hope this helps some.

Regards,

Steven Cheng
Microsoft Online Community Support


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

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

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


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



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default RE: How to set output page cache for all pages at once? - 05-29-2006 , 08:16 AM



Hello Jason,

How are you doing on this issue or does the info in my last reply helps you
a little? If there is still anything we can help, please feel free to post
here.

Regards,

Steven Cheng
Microsoft Online Community Support


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

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

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


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



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.