473,769 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Caching with ASP.NET, can I use page directive programmaticall y

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 programmaticall y, 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="no ne"%>, 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 1573
You can use the Response.Cache object to do it programatically ....

For example:
Response.Cache. SetExpires(Date Time.Now.AddSec onds(60));
Response.Cache. SetCacheability (HttpCacheabili ty.Public);
Response.Cache. SetValidUntilEx pires(true);
Response.Cache. VaryByParams.Ig noreParams = 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.netvis ion.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 programmaticall y, 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="no ne"%>, 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
2135
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. After looking at the use of the OutputCache directive and tinkering with it a bit I found its usability.very limited. Think of it: it is okay for static content. Well that's nice but no big deal. Static content is cheap anyway, the file system...
3
1642
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 calculated on the fly when the request is made, and so I thought it would be ideal to cache the page for a set amount of time. I've placed the following at the top of my page: <%@ OutputCache Duration="160" VaryByParam="None" %> Now the problem is...
0
1318
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 at the end of this message. The Microsoft documentation is a bit confusing to me. The following numbered sentences appear in the .NET Framework Developer's Guide article titled "Caching Portions of an ASP.NET Page": 1. You can declare an ID...
2
1589
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 that are retrieved from the database and would like to avoid retrieving it every time the page is accessed, could I use the above directive and include the following statement in the Page_Load event?
4
1202
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 file in the cache and added a dependency so it will notice when the file changes. All fine so far. I was reading last night about using the OutputCache page directive to store the page in the cache. It seems you can do this for a user control
10
1470
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 anyway to cache the page without this happening or am I using Page Output caching in the wrong situation? It's a data entry web app that I'm trying to increase the performance on.
3
2489
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 want caching on. Is this doable? I think there is a config switch in 2.0, anything in 1.1? TIA for any hint,
0
1139
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 isn't described in these resources (kb/docs). Brief: -----
3
1755
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 controls, each of which queries a SQL Server database for their content. The content is not likely to change frequently at all - so I'd like a way to cache the final page upon first request. Then subsequent requests are served from the cache -...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.