Page Caching help needed

A

Adrian Parker

IE.. Tools -> Internet Options -> Settings Button ->
Check for newer versions of stored pages = Never

If a user changes thier settings to this, then pages are cached in IE.

From what we've found, you have to use the following Meta tags in the HEAD
section to stop it doing it.

meta http-equiv="Pragma" content="no-cache"
meta http-equiv="Expires" content="0"

However, due to a problem, if the page is less than 64k, you have to
add a 2nd HEAD section after the BODY and include the two meta tags again.
e.g.

<HTML>
<HEAD>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
</HEAD>
<BODY>
yada yada yada
</BODY>
<HEAD>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
</HEAD>
</HTML>

else the pages are still cached.

To get the thing working and out there, I've added the 2nd head tags to each
aspx page.

Is there a better way of doing this?

Thanks
Adrian
 
T

Teemu Keiski

Have you tried just adding

< %@Outputcache Location="None" % >

directive after @Page directive. It should set headers so that caching is
disallowed.
 
A

Adrian Parker

Hi Teemu,

No I haven't.. probably because I didn't know about it :)
Is there any way of automating the addition of the code to the top of each
page, or is it another manual process ?

Thanks
Adrian
 
T

Teemu Keiski

Yes, it can be done with code also, and if you want it for every page, you
can do it from Global.asax and Application_BeginRequest (for example).

Response.Cache.SetCacheability(HttpCacheability.NoCache)

Here is more about the feature
http://msdn.microsoft.com/library/d...guide/html/cpconsettingcacheabilityofpage.asp

There is also a bigger mixture of variations possible. For example

Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.AddHeader ("Pragma", "no-cache")
Response.Expires = -1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top