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.
Archived Comments
It not only breaks some browser rendering, it breaks most XML parsing as I learned while trying to implement some basic RSS/Atom feed caching. I was disappointed to see the problem was still in CF8, but very glad to learn it was fixed in 8.0.1. I ended up just using cfschedule to cache higher traffic feeds. It works fine for a few things, but could be tough to manage with a large number of pages.
Would something taking advantage of getPageContext() work? I have had to do content replacement with that before.
<cfset content = getPageContext().getOut().getString()>
<cfset content = rereplace(content, "^<!--.*?-->$", "")>
<cfcontent reset="Yes">
#content#
Untested - I am just spit-balling.
Wow, that's a no - cuz even without the cfsavecontent it fails. It must be that it's being used inside a CFC method.
You could use the content filter function of FusionReactor?
Even though it states in the release notes that the cfcache 'heading' comment has been fixed for xhtml compliance in 8.01 release - and states in the release notes that it has been fixed - "70372 The cfcache tag inserted a comment that invalidated XHTML and XML
pages.
Tags - cfcache"
it's still appearing in our headers on an 8.01 upgraded server (we're not the only ones http://software.groupbrowse...
Any one still seeing this after an upgrade?
I posted the message you linked to. :) Unfortunately I'm back here because I'm still searching for an answer. It's perplexing, given that Adobe says they've fixed this bug.
Ditto on this, just tried cfcache on my server and still have this comment tag appearing breaking xhtml compliance.
how annoying!