Skip to main content
Ben Nadel at Scotch On The Rock (SOTR) 2010 (London) with: Matthew Bourke and Jim Cumming
Ben Nadel at Scotch On The Rock (SOTR) 2010 (London) with: Matthew Bourke ( @gummatt ) Jim Cumming ( @jimcumming )

Checking To See If CFFlush Has Already Been Executed Part II

By on

A while back, I posted that you could check to see if CFFlush had been executed earlier in the page processing by trying to set the header and catching any errors that were thrown. This morning, though, I was poking around in ColdFusion's page context (returned via GetPageContext()) and it turns out there is a much more simple way to do this; all you have to do is check to see if the response headers have been committed (written to the output stream):

<!--- Check to see if a CFFlush tag has been executed. --->
CFFlush: #GetPageContext().GetResponse().IsCommitted()#

<!--- Flush the page. --->
<cfflush />

<!--- Check to see if a CFFlush tag has been executed. --->
CFFlush: #GetPageContext().GetResponse().IsCommitted()#

This gives us the output:


That's some easy stuff right there. No, keep in mind, this is not just for the CFFlush tag. This is a general way to see if content has already been sent to the browser.

Want to use code from this post? Check out the license.

Reader Comments



Thanks for the heads up on the www issue. I have to say that both work for me. But, I talked to one of my more server-savvy co-workers and he says that while all the server stuff is set up to handle it, there is a chance IIS doesn't have it correct. We are waiting for our production box login (from my boss) and we will check the host headers.

I of course know nothing about all this jazz :)

Glad you are enjoying the posts. I am working my way through posts right now. I unfortuantely cannot contribute opinions regarding DAO vs. Gateways cause I don't know that stuff yet... but hopefully I will soon.



The server guys here tell me there is no reason that should not be working. Do you have any suggestions?


No trouble here viewing your site with www. infront of the domain name. A great post. I've seen the same implemented in the index.cfm of cfwheels (but for a different purpose than cfflush but still deals with output to the browser) and currently use it myself for something new I built. Comes in handy.


Ooops - sorry having u chase round Ben - my bad.

Did a link in a comment to your site and had a period in the URL so it was that didn't work (trailing period). Sorry about that! I've just been caught out by the www thing back when I first started admin'ing my sites and I jumped to the (wrong) conclusion.

Say sorry to the server guy for me!

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel