Here I would discuss strategies to disable caching in your pages especially related to ASP.net and MOSS 2007.
If you wanted to prevent caching in plain old HTML, you would use these directives
<meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache">
I wont explain these tags here. You can refer to W3C HTML specification. Rather I would focus on how
to insert these HTML tags while developing in ASP.NET and MOSS 2007 i.e. master - content pages.
1) If you using plain aspx pages you can directly put these tags under the
<head> section and you are done.
If you are using master - content pages, you can add this to master page but beware, this will prevent
caching of all the pages.
Usually you are looking to prevent the caching of single page which contains dynamic data.
In that case, you can use strategies given below.
If you are using MOSS 2007, and want to prevent the caching of a content page, there are two choices:
2) Add a contentplaceholder inside the <head> in your master page. Then inany pages that need these headers, populate the content control withthese meta tags. Other pages don't need to populate (or even have) thecontent control.I do this a lot and it's much easier
If you want to do this programmatically, you can put this line in a webpart or custom control :
Page.Master.FindControl("Content PlaceHolder").InnerHtml = < no caching tags>
3)
This is a small piece of code, which programmatically adds the <meta http-equiv="refresh" ... />
to the <head> page.
void DisableBrowserCaching(HtmlHead hdr){Control ctrl = (Control)hdr;string currGMT =DateTime.Now.ToUniversalTime().ToLongDateString() +" " + DateTime.Now.ToUniversalTime().ToLongTimeString() + "GMT";HtmlMeta meta = new HtmlMeta();meta.Name = "expires";meta.Content = currGMT;ctrl.Controls.Add(meta);meta = new HtmlMeta();meta.HttpEquiv = "pragma";meta.Content = "no-cache";ctrl.Controls.Add(meta);meta = new HtmlMeta();meta.HttpEquiv = "cache-control";meta.Content = "no-cache";ctrl.Controls.Add(meta);}
You can use this code like this, in your controls or webparts
HtmlHead hdr = Master.Page.Header;util.DisableBrowserCaching(hdr);
or if you are not using master pages, you can directly pass the Page.Header.
Can this work in the wiki pages content in MOSS?
wiki pages are just part of the full page in moss consisting of master page as well. You cannot add code directly to the wiki pages in moss..