473,513 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cache problem

Now here i have a doubt
the explorer maintains the cache for 300 seconds when the code is in
html code like the one which is below :-
<%@ OutputCache Duration="300" VaryByParam="none" %>
But the same code when typed in the cs file of the page does not gives
the same result.

Response.Cache.SetExpires(DateTime.Now.AddSeconds( 60));
Response.Cache.SetCacheability(HttpCacheability.Pr ivate);
Im not able to guess as to you the page is not been cached for 300
seconds

Jan 16 '06 #1
2 1180
Hello Jack,
Now here i have a doubt
the explorer maintains the cache for 300 seconds when the code is in
html code like the one which is below :-
<%@ OutputCache Duration="300" VaryByParam="none" %>
But the same code when typed in the cs file of the page does not gives
the same result.

Response.Cache.SetExpires(DateTime.Now.AddSeconds( 60));
Response.Cache.SetCacheability(HttpCacheability.Pr ivate);
Im not able to guess as to you the page is not been cached for 300
seconds


Well, 60 seconds and 300 seconds are not the same ;-)

Your second approach doesn't set the CacheControl: max-age header, either.
To achieve the same as the OutputCache directive in code, use

// You could also use new TimeSpan(0, 0, 300), but 5 minutes is more readable
than 300 seconds :-)
TimeSpan maxAge = new TimeSpan(0, 5, 0);
Response.Cache.SetExpires(DateTime.Now.Add(maxAge) );
Response.Cache.SetCacheability(HttpCacheability.Pr ivate);
Response.Cache.SetMaxAge(maxAge);

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jan 16 '06 #2
ok thanks

Jan 17 '06 #3

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

Similar topics

3
32827
by: Bite My Bubbles | last post by:
I found the answer! It is a IIS 6 /ASP problem http://support.microsoft.com/default.aspx?scid=kb;en-us;332075
1
2496
by: Joe Fallon | last post by:
I am trying to setup a cache that refreshes itself every hour. (My sample code is for every minute so I can test it.) I have found some examples that I thought worked but they all seem to fail....
13
1760
by: Fernando Chilvarguer | last post by:
Hi, I'm retriving data from a database and storing it on the Cache Object using the following code: HttpContext.Current.Cache.Insert( cacheItemKey, contentDS, //THE DATASET WITH MY DATA...
6
1751
by: Adam | last post by:
On an xp machine, the caching works as expected. I have deployed to a win2k server, and an item I add to the cache expires almost immediately some times and in under a minute in other times. The...
5
2106
by: Arjen | last post by:
Hi, I'm using the cache block of the enterprise lib Jan. 2006. There is somethings strange going on. I add a varable to the cache, let's say the string myData. string myData = "1111111";...
3
1913
by: Aryan | last post by:
Hi, I have problem related to Caching of data. I am reading large xml file and putting this xml in dataset, since this dataset will contain many datatable's inside. And each datatable might be big...
1
1390
by: =?Utf-8?B?ZGF2ZQ==?= | last post by:
I have an asp.net project with a business layer (project) that has a class called references. It loads up a data set and stores in cache with the following code. _cached =...
2
2647
by: moondaddy | last post by:
I had to repost this because I had to update and change my msdn alias. I will re-ask the question and clarify a few things that were not clear before. This code is all executed on my dev...
5
2268
by: J055 | last post by:
Hi The following code works on my develeopment machine using the VS web server. When I run the application on 2 other Windows 2003/IIS 6 servers no caching seems to take place at all. Can...
0
2409
by: Hypnotik | last post by:
My program is to simulate cache memory. I read in the info from 2 external files, 1) access 2) data in memory. When I read the information in I display the info...and it is all correct. However...
0
7175
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
7391
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
7553
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...
1
7120
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
5697
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,...
1
5100
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...
0
4754
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...
0
3247
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...
0
1609
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 ...

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.