I know this question has been asked a dozen times but in all the posts I can't find an answer that works for me.
I am trying to completly disable all cache from a page, so when the user goes back using the browser buttons, there appears the typical sign of "This page has expired".
I have already tried removing the OutputCache directive, with the same results. I was expecting that by caching the page for 1 second, after that second it would discard it. I've tried usind another value, but OutputCache doesn't accept non-positive numbers.
As I wrote in my previous post I have already used the meta tags and I didn't mention it, but the "response" code is in the page_load too.
Setting the OutputCache for 1 second displays the content from cache for one second and after that any new request will get data from server. I tried the code you have given and its displaying the typical page expired message.
I've created a small hellowWorld type project, implementing the cache disabling method discussed.
There are just 2 pages and one of them contains a linkButton to the other. I've built the project and uploaded it to a web server but I still don't have the desired result. I've tried it using explorer 6.0 and mozilla firefox 2.0.
If anyone would be so kind, could you have a look at it. You can find it zipped inside the following address.
rankor20
0 Points
4 Posts
How to disable cache
Jan 05, 2007 01:29 PM|LINK
I know this question has been asked a dozen times but in all the posts I can't find an answer that works for me.
I am trying to completly disable all cache from a page, so when the user goes back using the browser buttons, there appears the typical sign of "This page has expired".
So far I've tried the page directive:
<%@ OutputCache Duration="1" Location="None" %>
The Meta tags:
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
And the code:
Response.ExpiresAbsolute = DateTime.Now
Response.Expires = -1441
Response.CacheControl = "no-cache"
Response.AddHeader("Pragma", "no-cache")
Response.AddHeader("Pragma", "no-store")
Response.AddHeader("cache-control", "no-cache")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetNoServerCaching()
But every time the back button is clicked, there appears the previost page.
How can I solve that?
Thanks
e_screw
All-Star
19530 Points
3894 Posts
Re: How to disable cache
Jan 05, 2007 02:42 PM|LINK
By OutputCache directive you asking to hold the page in cache for 1 second. You need to remove that if you dont want to cache it.
Add these lines in the html meta section
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
and in the page_load write this
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Thanks
Electronic Screw
Website||Blog||Dub@i.net
rankor20
0 Points
4 Posts
Re: How to disable cache
Jan 05, 2007 03:40 PM|LINK
I have already tried removing the OutputCache directive, with the same results. I was expecting that by caching the page for 1 second, after that second it would discard it. I've tried usind another value, but OutputCache doesn't accept non-positive numbers.
As I wrote in my previous post I have already used the meta tags and I didn't mention it, but the "response" code is in the page_load too.
I also didn't say that I'm using asp.net 2.0
Thanks
e_screw
All-Star
19530 Points
3894 Posts
Re: How to disable cache
Jan 05, 2007 03:58 PM|LINK
Setting the OutputCache for 1 second displays the content from cache for one second and after that any new request will get data from server. I tried the code you have given and its displaying the typical page expired message.
Thanks
Electronic Screw
Website||Blog||Dub@i.net
rankor20
0 Points
4 Posts
Re: How to disable cache
Jan 31, 2007 06:34 PM|LINK
I've created a small hellowWorld type project, implementing the cache disabling method discussed.
There are just 2 pages and one of them contains a linkButton to the other. I've built the project and uploaded it to a web server but I still don't have the desired result. I've tried it using explorer 6.0 and mozilla firefox 2.0.
If anyone would be so kind, could you have a look at it. You can find it zipped inside the following address.
http://www.bersatil.com/helloworldcache.zip
Thank you for your time
Jerome Cui -...
Star
12018 Points
1080 Posts
Re: How to disable cache
Feb 02, 2007 11:46 AM|LINK
Hi, rankor20
After seriously study your problem, this solution is here:
http://www.codeproject.com/useritems/NoCaching.asp
Hope this helps.
Please "mark as answer" if it's useful for you
Sincerely,
Jerome
navaneethkn
Member
523 Points
141 Posts
Re: How to disable cache
Aug 17, 2007 12:35 PM|LINK
It failed to work with Firefox. It works with IE perfectly
Navaneeth.K.N
www.w3hearts.com
If this post was useful to you, please mark it as answer. Thank you!
Indranil Mut...
Member
2 Points
1 Post
Re: How to disable cache
Apr 20, 2010 07:17 AM|LINK
http://www.codeproject.com/useritems/NoCaching.asp
This projectis no longer available here. Can i get it from somewhere???
no caching
niralpatel
Contributor
2391 Points
452 Posts
Re: How to disable cache
Apr 20, 2010 07:23 AM|LINK
hi,
http://www.freevbcode.com/ShowCode.Asp?ID=243
hope this will help you more
or Let me know for Further help.
Thanks
Niral Patel
(INDIA)
cin ruhi
Member
4 Points
2 Posts
Re: How to disable cache
Sep 04, 2010 10:37 PM|LINK
I have the same problem with Firefox. Could you solve the problem? I need to disable caching for Firefox.
Thanx in advance.