Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / May 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jason - 24 May 2006 16:43 GMT
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?
Steven Cheng[MSFT] - 25 May 2006 06:20 GMT
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.__outputCacheSettings);
     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.

Signature

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

Steven Cheng[MSFT] - 29 May 2006 13:16 GMT
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.

Signature

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


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.