How not to cache a page output in ASP.NET

[ad] Tip: Websites based on would benefit from hosting because it was specially designed to ensure error free work of scripts.

In one of my post, I posted about How to cache a page output in ASP.NET, but sometime you have requirement like the page should never be cached. Every time user request a particular url it should give you fresh version of the page or file. To achieve this simply added Location="None" to the OutputCache directives.

<%@ OutputCache Location="None" VaryByParam="None" %>

Using Location="None" will tell the browser not to cache the page and hence your can prevent the page from saving on temporary internet files on client's machine. This could be useful when you don't want you pages or some particular page to be stored at client side for security reasons.

19 comment(S)

PP on Aug 4, 2008 05:16 PM

Word "" is mis-spelled :)

samiran on Sep 7, 2008 09:55 PM

hey there i am a beginner of and wanted to learn something more day by day well this is a very good thing i came to know as its very helpful for me...
thanks buddy

gfdfgdgdgd on Jul 27, 2009 12:27 AM

gfdfgdgdgd on Jul 27, 2009 12:27 AM


Jack on Sep 6, 2009 10:38 PM

and we can use velocity or other cache server to help us.

watson on Feb 3, 2011 03:42 AM

agreed man, there are some very good third party distributed cache providers are available to help the case.along with Velocity (now called as Appfabric), NCache also provides cache server.

Sankar on Apr 28, 2011 07:36 PM

but still my webform storing data in cache :(

guide me pls....


Omar on Aug 20, 2011 11:49 AM

thaaaaaaaaaaaaaaaaaaaaax dude :)

Omar on Aug 20, 2011 11:50 AM

But man i have a question ,,, is there any configuration for the browser to make it cache the page ???????????


Buddhika Gayan on Apr 2, 2012 09:12 PM

Lot of thanks.. It's working....

venkat on Jun 2, 2012 03:30 AM

how to set expiration date tpo an old date in the same tag

Josh on Oct 15, 2012 11:10 PM

I think NCache is the best suit for this , App Fabric i tried i cannot reply much on that

Marco on Nov 26, 2012 04:37 AM

Perfect... exactly what I looking for.

suresh on Apr 6, 2013 04:48 AM

i am not satisfied with cache u write above for not to store a page in cache

snehalata on Apr 19, 2013 12:00 AM

I try this but not worked.I wan On click of imagebutton page does not cache.

ddd on May 30, 2014 05:22 AM

asdad on Feb 13, 2015 03:26 AM


Leave a comment