I’m writing a new import module for our real estate system where I have to read several XML files and process many photos, resizing them for the web and updating the database. Due to the amount of picture files to process, I was getting CF tag timeouts, sometimes the image tag, sometimes other tags. So instead of doing everything in one processs looping through all XML files, I decided to pick the first one up and process it, and at the end I put a CFLOCATION to call itself to process the next file until there are no file to process.
The template worked well, did everything it had to do, but stopped at the end without calling itself to process the next file, and did not throw any error.
It took me a long time troubleshooting it, then I found an article by Peter Freitag about the tag CFLOCATION performing a client redirection where he mentioned another option of using CFHEADER to redirect:<cfheader statuscode="301" statustext="Moved Permanently">
<cfheader name="Location" value="http://www.website.com/">
That didn’t work either, but at least threw an error saying something about the page had been flushed.
Well, looking at my code I could see the several <cfflush> tags I had to track the process in real time. As soon as I took them out of the code, the template worked perfectly.
So I wrote this post just to admit my stupidity and to alert our colleagues not to use the combination CFFLUSH and CFLOCATION.
Yep, that’s correct… Once you have done a CFFLUSH you can’t change the HTTP headers (which is how CFFLUSH works), as they have already been sent.
I meant to say that HTTP headers is how CFLOCATION works :S
You’re right Shannon, I learned it the hard way.
Thanks for your comment.
I get very frustrated that almost nothing about the modern web is ever explained frontwards. It’s all so anecdotal and tips and trickster-y. Like it were just a big game of dungeons and dragons.
For newbies:
is a tag which starts a set of HTTP headers that will eventually redirect a browser when sent.
will clear any HTTP headers that have been generated but not sent.
The operations and relationship are not mysterious, and do not require geekdom, guruship, wizardry, nor genius.