473,782 Members | 2,423 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 1576
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
2136
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
1203
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
1472
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
1756
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
9643
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
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
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
10147
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...
1
10081
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7494
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
6735
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
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2875
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.