473,404 Members | 2,213 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,404 software developers and data experts.

Disabling page caching not working

Hi All,

Can anyone please explain me why I am not able to disable Browser caching in
ASP.net by writing the following code

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.Subtract(new TimeSpan(1, 0,
0, 0));
Response.Expires = 0;
Response.CacheControl = "no-cache";

To test if it is working, I wrote the above code in the page load event
handler of a ASPX page called Page1.aspx. I added a Button with a click event
handler which posts the page to a second page Page2.aspx. Now when I press
back button on the browswer while in Page2.aspx, I get page1.aspx. I should
be getting page expired error page, but what I have observed is that whenever
i press back button on the browswer, page1.aspx is freshly loaded (I put
break on page_load event handler to find this out).

I also tried to write this code in the page_load event of Page1.aspx instead
of the four lines of code

Page.Response.Cache.SetCacheability(HttpCacheabili ty.NoCache);

The above code is also not working. I am using IE 7.0.

thanks
pradeep

Apr 11 '08 #1
3 2495
I'm not sure I understand why you expect a "page expired" message. If
caching is disabled, the page would simply be re-requested by the browser,
exactly as you describe...
Peter

"pradeep_TP" <pr*******@discussions.microsoft.comwrote in message
news:BF**********************************@microsof t.com...
Hi All,

Can anyone please explain me why I am not able to disable Browser caching
in
ASP.net by writing the following code

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.Subtract(new TimeSpan(1, 0,
0, 0));
Response.Expires = 0;
Response.CacheControl = "no-cache";

To test if it is working, I wrote the above code in the page load event
handler of a ASPX page called Page1.aspx. I added a Button with a click
event
handler which posts the page to a second page Page2.aspx. Now when I press
back button on the browswer while in Page2.aspx, I get page1.aspx. I
should
be getting page expired error page, but what I have observed is that
whenever
i press back button on the browswer, page1.aspx is freshly loaded (I put
break on page_load event handler to find this out).

I also tried to write this code in the page_load event of Page1.aspx
instead
of the four lines of code

Page.Response.Cache.SetCacheability(HttpCacheabili ty.NoCache);

The above code is also not working. I am using IE 7.0.

thanks
pradeep
Apr 11 '08 #2
I'm not sure I understand why you expect a "page expired" message. If
caching is disabled, the page would simply be re-requested by the browser,
exactly as you describe...
Peter

"pradeep_TP" <pr*******@discussions.microsoft.comwrote in message
news:BF**********************************@microsof t.com...
Hi All,

Can anyone please explain me why I am not able to disable Browser caching
in
ASP.net by writing the following code

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.Subtract(new TimeSpan(1, 0,
0, 0));
Response.Expires = 0;
Response.CacheControl = "no-cache";

To test if it is working, I wrote the above code in the page load event
handler of a ASPX page called Page1.aspx. I added a Button with a click
event
handler which posts the page to a second page Page2.aspx. Now when I press
back button on the browswer while in Page2.aspx, I get page1.aspx. I
should
be getting page expired error page, but what I have observed is that
whenever
i press back button on the browswer, page1.aspx is freshly loaded (I put
break on page_load event handler to find this out).

I also tried to write this code in the page_load event of Page1.aspx
instead
of the four lines of code

Page.Response.Cache.SetCacheability(HttpCacheabili ty.NoCache);

The above code is also not working. I am using IE 7.0.

thanks
pradeep
Jun 27 '08 #3
I do not want to show the previous page when the user clicks on the back
button on the browswer. All I want it that when the back button is pressed,
the standard "page expired" page should be shown.

You are right, now I understand that if I disable the page caching, the page
would be requested from the server. But how would i make the browser show
only the page expired message ?

thanks
pradeep

"Peter Bromberg [C# MVP]" wrote:
I'm not sure I understand why you expect a "page expired" message. If
caching is disabled, the page would simply be re-requested by the browser,
exactly as you describe...
Peter

"pradeep_TP" <pr*******@discussions.microsoft.comwrote in message
news:BF**********************************@microsof t.com...
Hi All,

Can anyone please explain me why I am not able to disable Browser caching
in
ASP.net by writing the following code

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.Subtract(new TimeSpan(1, 0,
0, 0));
Response.Expires = 0;
Response.CacheControl = "no-cache";

To test if it is working, I wrote the above code in the page load event
handler of a ASPX page called Page1.aspx. I added a Button with a click
event
handler which posts the page to a second page Page2.aspx. Now when I press
back button on the browswer while in Page2.aspx, I get page1.aspx. I
should
be getting page expired error page, but what I have observed is that
whenever
i press back button on the browswer, page1.aspx is freshly loaded (I put
break on page_load event handler to find this out).

I also tried to write this code in the page_load event of Page1.aspx
instead
of the four lines of code

Page.Response.Cache.SetCacheability(HttpCacheabili ty.NoCache);

The above code is also not working. I am using IE 7.0.

thanks
pradeep
Jun 27 '08 #4

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

Similar topics

1
by: Keith Chadwick | last post by:
How do I prevent caching on a page. I tried <%@ OutputCache Duration="1" VaryByParam="None" %> but that does not appear to be working. The content of the page is generated by the loading of 2 xsl...
0
by: Troy Simpson | last post by:
Hi, I have a website which is made up of dynamic pages. Each page that's loaded has some code which looks at which template to load amongst other things, which causes the page to take a little...
9
by: Paul Keegstra | last post by:
Hi, I am currently working on an asp.net 2.0 web site that is a replacement of a classic asp web site. The current web site uses a Commerce Server 2002 database for storing user information. ...
1
by: Oleg | last post by:
Hi, I'm having a problem with page caching and therefore reusing dropdown box contents. Scenerio: user1 has security to see list of three items(.aspx populates it with three items only) in...
11
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some pages that must not be cached on the client. In ASP.NET 1.1 I achieved this using metatags: <meta...
0
by: Jeff | last post by:
The following code works to disable page caching in IE6, but doesn't work in Firefox. Does anyone know what will work in Firefox and/or other browsers? Response.Buffer = True...
1
by: priya0123 | last post by:
Hi, We are writing an application in asp.net 2.0. We have used menu control and made it a usercontrol. I have Partial cached the user control. After caching the user control, this is being...
0
by: itfetish | last post by:
We have a web parts intranet at our office here I have been working on. I have been trying to create a way of getting our OCE TDS 600 plotter queue to be a web part on the page, seeing as their...
8
by: Harvey Schmidlapp | last post by:
I have a fairly complex form (generated by means of an ASP 3 page). The form is used to define a query against a database. After running a query, the user hits their browser's back button and goes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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.