Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2005, 07:30 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page caching

Hello,

I'm using page caching and was wondering if for this tag:

<%@OutputCache Duration="60" VaryByParam="id" %>

i could store the duration somewhere else, eg the web.config.

 
Old December 12th, 2005, 01:57 PM
Authorized User
 
Join Date: Nov 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

    Sure you could and you must, because this is more easy way to change the value on every page.

François

 
Old December 14th, 2005, 01:46 PM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry i meant "could I", not "i could"! I've figured it out now anyway. Here's how if anyone wants to know.

Put this code in the code-behind for the page you want to cache:

int duration = Convert.ToInt32(System.Configuration.Configuration Settings.AppSettings["CacheDuration"];);
Response.Cache.SetExpires(DateTime.Now.AddSeconds( duration ));
Response.Cache.SetCacheability(HttpCacheability.Pu blic);

and in the Web.Config put this tag in the AppSettings section:

<add key="CacheDuration" value="60" />

where value is the time in seconds you want the pages to be cached for.

 
Old January 9th, 2006, 07:58 PM
Registered User
 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another option that seems usefull is an IIS tool called www.cacheright.com which allows you to write expiration rules based on mime type, file type, and directory without having to write any code.

There is also a neat cache check tool that shows you what files are good candidates for caching: www.port80software.com/support/p80tools






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to refresh the page without allowing caching malay mehta PHP FAQs 0 March 5th, 2007 01:22 AM
Problem of Stored Page caching in IE snowbydave1 Other Programming Languages 1 March 2nd, 2007 09:37 AM
Problem of Stored Page caching in IE snowbydave1 PHP How-To 2 March 1st, 2007 03:06 AM
best way to prevent page from caching crmpicco HTML Code Clinic 2 March 17th, 2006 09:02 AM
Preventing Page Caching neeter HTML Code Clinic 3 June 5th, 2003 01:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.