473,414 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Caching with ASP.NET, can I use page directive programmatically

I am impressed by the caching performance of .NET. However, there is one
major obstacle that I haven't managed to solve yet.

What I want to do is the following: I have a normal site, and a preview
site. The normal site should have maximum performance, thus uses caching.
The preview site is for internal use only, and should not use caching, since
our content managers will want to see the updates directly. The only
difference between the two sites is the web.config file.

If I use caching programmatically, then everything works out great, I add a
key in the webconfig, and only if this is the normal site then it will do
caching, otherwise it won't.
But if I use the caching through the page directives, <@OutputCache
Duration="300" VaryByParam="none"%>, then I can't vary this anymore between
my preview site and my normal site.

How can I overcome this problem?

Leo Muller
Nov 18 '05 #1
1 1559
You can use the Response.Cache object to do it programatically....

For example:
Response.Cache.SetExpires(DateTime.Now.AddSeconds( 60));
Response.Cache.SetCacheability(HttpCacheability.Pu blic);
Response.Cache.SetValidUntilExpires(true);
Response.Cache.VaryByParams.IgnoreParams = true;

http://msdn.microsoft.com/library/de...lityofpage.asp

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leo Muller" <le***@keshet-i.com> wrote in message
news:cn**********@news2.netvision.net.il...
I am impressed by the caching performance of .NET. However, there is one
major obstacle that I haven't managed to solve yet.

What I want to do is the following: I have a normal site, and a preview
site. The normal site should have maximum performance, thus uses caching.
The preview site is for internal use only, and should not use caching, since our content managers will want to see the updates directly. The only
difference between the two sites is the web.config file.

If I use caching programmatically, then everything works out great, I add a key in the webconfig, and only if this is the normal site then it will do
caching, otherwise it won't.
But if I use the caching through the page directives, <@OutputCache
Duration="300" VaryByParam="none"%>, then I can't vary this anymore between my preview site and my normal site.

How can I overcome this problem?

Leo Muller

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Martin | last post by:
Hi. I had a very frustrating afternoon and evening but I have got it all under control now so all of a sudden I am in a good mood. I want to share some insights on output caching with you lot. ...
3
by: Janaka | last post by:
Hi All, I'm having a problem with Page Output caching on a page that contains a DataGrid. Basically the page pulls up some data for sales information from the DB. Some of this has to be...
0
by: Jeff Schaefer | last post by:
What I want to know is this: Is it possible to programmatically manipulate a custom property of a user control for which <%@ OutputCache ... > has been included? If so, then how? My brief code is...
2
by: Mike | last post by:
Hi, If I turn on the caching for a page with the following directive: <%@ OutputCache Duration="600" VaryByParam="None" %> will the Page_Load event always fire? If I have some static data...
4
by: Alan Silver | last post by:
Hello, I tried out using the cache the other day and was impressed with the concept. I built myself a custom control to generate the site links, using an XML file for the info. I kept the XML...
10
by: BillGatesFan | last post by:
I'm trying to understand ASP.NET caching. I set the Page Output directive to VaryByParams= None and the duration = 60. Now whenever users hit my web app they can see each others data. Is there...
3
by: DC | last post by:
Hi, (ASP.Net 1.1) is it possible to (programmatically and globally) deactivate page fragment caching? We have only two scenarios, development stage where we want caching off and testing where we...
0
by: Ed | last post by:
Hi all, Have a strange situation regarding fragment caching. I've read the docs and kbs on this so it's either I've missed some key aspect of the implementation or there is a "gotcha" here that...
3
by: Smithers | last post by:
Just wondering what it would take to cache a copy of the output HTML from a dynamically constructed aspx page before it is sent to the browser. Reason being: the page is constructed of a few user...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.