How can I prevent a browser from caching my page?
By default, browsers will try to cache the contents of a page. Because of their dynamic nature, most ColdFusion pages will automatically force a browser to reload them on each visit. However, you may still want to keep the contents of a more static page (for security or other reasons) from being cached. In these types of situations, you can use the <cfheader> tag or the html <meta> tag.
Place the following three <cfheader> tags at the top of a page to keep it from being cached:
<cfheader name="pragma" value="no-cache">
<cfheader name="expires" value="#getHttpTimeString(now())#">
You can also use set a meta tag for content expiration
This question was written by Jeremy Petersen.
It was last updated on February 7, 2006 at 10:50:01 AM EST.
CFML Referenced
Categories
Comments
Comment made by Simon Bailey on February 13, 2007 at 3:31 PM
Hi, I was wondering on how I could impliment the above into a cfc to save repeating the code in each individual cfm page?
Ta Simon