bpurcell.org - Preventing browsers from caching ColdFusion pages
Calendar
SunMonTueWedThuFriSat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      

Subject Archives
Amazon EC2 (15)
ColdFusionMX (155)
Corvette (3)
Flash Lite (4)
Flash Media Server (5)
Flash Player (3)
Flex (39)
General Web Dev (14)
HDTV (3)
Jboss (1)
Jquery (2)
JRun (59)
Max 2003 (3)
Other (33)
PC Hardware (16)
Software (17)
SpatialKey (7)
Wireless (8)
Working Out (1)

RSS Feed
Feed Listing

Site Contents
Home
My Blog
ColdFusion
JRun
Flex
Wireless & Networking
Hardware & Gadgets
HDTV
Software Picks
Pictures
Contact Me
Search


My Articles & Papers
Flex Performance
Server/Client
mm.com Under the Hood
Multiple Instances of CFMX
Multiple Instance Config
NLB with ColdFusion
Clustering CFMX for J2EE
Multi-Tier Hardware LB w CFMX
Cisco CSS & Coldfusion MX
JRun 4 Jini based Clustering
WiFi Growth

2ID Tacweb

Other Hobbys
Body-For-Life Challenge

Personal Projects
Family Pool
Deck Gate

username:
password:
 

 
Viewing Individual Entry / Main
November 25, 2005
I have ran into this several times before but I always forget the exact code so I figure I would blog it so I had a reference to it.  There are several ways to prevent pages from being cached, I have found that a combination of approaches works best.   This will make sure that it will work across all browsers

Set a meta tag for content expiration

<meta http-equiv="expires" content="Mon, 06 Jan 1990 00:00:01 GMT"> 

You can also use CFHEADER to send a header to the browser forcing it not to cache the data

<cfheader name="expires" value="#now()#"> 
<cfheader name="pragma" value="no-cache">
<cfheader name="cache-control" value="no-cache, no-store, must-revalidate">

see also: http://www.web-caching.com/mnot_tutorial/how.html

Comments

When using IIS you can simply set a caching directive at either a global or site level by accessing the property pages for the correct node and selecting HTTP Headers and adding in your headers there.

I normally use Cache-Control: no-store for development so that nothing is ever cached.

Although setting it for CF pages on production is probably most easily handled using the <cfheader/> tag.

Good post Brandon.


For a great explanation for the technical justification for these sort of cache settings (and some useful insights) see the Microsoft article on using Fiddler, which beyond discussing the tool also gives great background on caching concepts, issues, and techniques.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/IE_Fiddler2.asp

Hope that's helpful.


thx

--------- http://tramadolize.bravehost.com/


For 'expires' you'll need to format the date to an HTTP-valid date.

<cfheader name="expires" value="#GetHttpTimeString(Now())#">

Eric P.


 
Page Render Time:265