This post is more than 2 years old.
I'm not a huge fan of the CFCACHE tag. It's a blunt instrument and I wish CF would natively roll in a nicer caching system (like, oh say, ScopeCache, not that I'm biased or anything). A user wrote in with a question about CFCACHE. Turns out that when you use cfcache, it outputs a HTML comment before the text which can totally break some browsers.
Luckily - this was actually one of the things fixed in 8.0.1.
Unluckily for the user - he was still on ColdFusion 7.
I thought I'd try to get fancy and use onRequest - another feature I'm not a big fan of - but this seemed like a perfect use for it. I tried something like so:
<cffunction name="onRequest" returnType="void"> <cfargument name="thePage" type="string" required="true"> <cfset var content = ""> <cfsavecontent variable="content"><cfinclude template="#arguments.thePage#"></cfsavecontent> <!--- look for comment at beginning ---> <cfset content = rereplace(content, ""^<!--.*?-->$"", "")> <cfoutput>#content#</cfoutput> </cffunction>
At first - this did nothing. Then I remember that the default behavior of cfcache is to cache both on the client and the server. I switched my cfcache tag to use action=servercache, but unfortunately, you can't use cfcache inside custom tags, and that includes tags like cfsavecontent.