Strip whitespace
After reading a comment from Dmitry Namiot that he posted on http://weblogs.macromedia.com/cantrell/archives/2005/01/eliminate_coldf.cfm, I tried it out.. but it didn't do what I wanted. Below I changed the code a bit so that I have all the control on what to strip and what not. I didn't want the code to be on 1 line.. for that you can just use the regular expression. "[[:space:]]{2,-}"... I wanted to have a certain control on what and how my code was stripped.
Put the code below in an onRequestEnd.cfm and see what it could do for your bandwidth!! A better solution is always welcome :-)
Oh.. and the servlet idea on the above post didn't do it for me.. it had problems with RDS, cflocation etc, etc.
<!--- copy the current contents of out (which is what cfmx will send to the browser at the end of processing) --->
<cfset pageContent = getPageContext().getOut().getString()>
<!--- now we have a copy, clear the out buffer --->
<cfset getPageContext().getOut().clearBuffer()>
<!--- tidy up --->
<cfset pageContent = reReplace(pageContent, chr(9),"", "all" )>
<cfset pageContent = reReplace(pageContent, " ","", "all" )>
<cfset pageContent = reReplace(pageContent, chr(13)&chr(10)&chr(13)&chr(10),chr(13)&chr(10), "all" )>
<cfset pageContent = reReplace(pageContent, chr(10)&chr(13),"", "all" )>
<!--- send our cleaned content to the browser --->
<cfset writeOutput(pageContent)>
<cfset getPageContext().getOut().flush()>
<!--- job done! --->
6259 viewed | Your opinion... | del.icio.us | Digg it | Tjarko @ 12/09/05 12:58 cet



