-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thanks for the reminder on that one! I was going to do that... I
even had RFC 2616 on my desk to look up how to do that, and I
completely forgot...
I've actually got some "real work" to do today (darn clients....
always interrupting my fun!), but once I get that taken care of, I'll
integrate the various suggestions on this & see if I can turn it into
a real tag....
Thanks again to everyone for the tips & pointers!
Best regards,
Zac Bedell
> -----Original Message-----
> From: Orlando Correa (ITSC) [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, December 20, 2000 5:55 AM
> To: CF-Talk
> Subject: RE: [Compress HTML output]
>
>
>
> Just check the cgi.http_accept_encoding for the existance of
> "gzip"....
>
> <CFDEFAULTCASE>
> <CFIF
> listcontainsnocase(cgi.http_accept_encoding,"gzip")><!--- AND NOT
> dev_server --->
> <CF_GZipPage LEVEL="7">
> <CFINCLUDE TEMPLATE="myheavypage.cfm">
> </CF_GZipPage>
> <CFELSE>
> <CFINCLUDE TEMPLATE="myheavypage.cfm">
> </CFIF>
> </CFDEFAULTCASE>
>
> -----Original Message-----
> From: Peter Stolz [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 19, 2000 8:30 PM
> To: CF-Talk
> Subject: RE: [Compress HTML output]
>
>
> This is great!
> One question though:
> The servlet version checks for the ACCEPT_ENCODING request
> header before it
> does the actual encoding.
> I don't know of a way to do this in CF. Any ideas?
>
> P.
>
>
> -----Original Message-----
> From: Orlando Correa (ITSC) [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 19, 2000 9:58 AM
> To: CF-Talk
> Subject: RE: [Compress HTML output]
>
>
> Hey Zach...
>
> After some testing... I implemented your code to test compression
> of a particularly large html file with some encouraging results...
> The
> uncompressed page was 165K and took 391 milliseconds to excute.
> The compressed page is 20K with an added server overhead of around
> 375K milliseconds... The savings in download time for the html, in
> this case,
> warrent further explortion of compressing certain "heavy" pages
> (87.8% compression on level 7). Thanks dude! Pretty slick.
>
> I've hacked on your code a bit to test it in our development
> enviornment...
>
> <cfif ThisTag.ExecutionMode EQ "Start">
> <cfset start_time=gettickcount()>
> </cfif>
>
> <cfif ThisTag.ExecutionMode EQ "END">
> <!--- Sane defaults: --->
> <cfparam name="Attributes.Level" default="9">
> <cfparam name="Attributes.Unique"
> default="#RandRange(1,10000000)#">
> <cfparam name="Attributes.Directory" default="c:\temp">
>
> <!--- set temp dir --->
> <cfset dir_compress = Attributes.Directory>
>
> <cfif not IsDefined("application.IsDir")>
> <!--- check if the directory exists --->
> <cfdirectory name="qry_checkdir" directory="#dir_compress#"
> action="LIST">
>
> <!--- if it doesn't exist, create new directory
> #dir_compress# --->
> <cfif not qry_checkdir.recordcount>
> <cfdirectory action="CREATE" directory="#dir_compress#">
> </cfif>
>
> <!--- set IsDir flag for by-passing directory check --->
> <cflock scope="application" timeout="10">
> <cfset application.IsDir = 1>
> </cflock>
> </cfif>
>
>
> <!--- Setup path & filename for tempfiles: --->
> <cfset RawHTMLFile =
> "#dir_compress##listlast(cgi.script_name,"/")#_#Attributes.Uni
> que#_#RandRang
> e(1,1000000)#.out">
> <cfset GZippedFile =
> "#dir_compress##listlast(cgi.script_name,"/")#_#Attributes.Uni
> que#_#RandRang
> e(1,1000000)#.in">
>
> <!--- Grab the generated content and write it out to a
> tempfile.--->
> <cfset end_time=gettickcount()>
> <cfset time = end_time-start_time & "Milliseconds">
> <cfset Content = Trim(ThisTag.GeneratedContent) & time>
> <cffile action="WRITE" file="#RawHTMLFile#" output="#Content#">
>
> <!--- Compress the tempfile to another tempfile --->
> <cfx_GZip action="GZIP" InFile="#RawHTMLFile#"
> OutFile="#GZippedFile#"
> level="#Attributes.Level#">
> <cffile action="delete" file="#RawHTMLFile#">
>
> <!--- Setup the headers and write the mess back out to the client
> w/CFCONTENT --->
> <cfset ThisTag.GeneratedContent = "">
> <cfheader name="Content-Encoding" value="gzip">
> <cfcontent file="#GZippedFile#" deletefile="Yes"
> type="text/html"> </cfif>
>
> -----Original Message-----
> From: Zachary Bedell [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 18, 2000 2:20 PM
> To: CF-Talk
> Subject: RE: [Compress HTML output]
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> > compression is a web server issue NOT CF.
>
> That's true, but it doesn't mean you can't do it in CF...
>
> Below is a custom tag that will do just that, provided you have
> CFX_GZip installed (freely downloadable from the tag gallery).
>
> I'm not sure whether the savings in bandwidth is worth the
> additional processor power (anyone wanna run tests?), but it's
> still nifty...
>
> One place this would really be a savings: If you already use
> CFCACHE, you should be able to modify the CFCache tag to also do
> compression before it saves a file. That way you only need to
> compress the file once, and you get the processor savings of
> CFCache AND the bandwidth savings of compression.
>
> I'll probably post this tag to the tag gallery once I beat on it
> for a little longer. In the meantime, enjoy...
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGPfreeware 6.5.8 for non-commercial use
> <http://www.pgp.com> Comment: Please use PGP!
>
> iQA/AwUBOj5/Z6vhLS1aWPxeEQKSRwCg+iRBf/fA8Y72IbopUMF0kM6NEkkAnj+k
> wwQDQrb5RkIfgaFn1TRaW8Ub
> =4/Jb
> -----END PGP SIGNATURE-----
>
> <!--- CF_GZipPage
> Make sure this tag surrounds the ENTIRE page. It will GZIP the
> GeneratedContent using
> CFX_GZip and modify the browser headers so that the browser can
> decode it.
>
> Anything that falls outside of the start and end tag for this
> tag
> will be ignored and never
> seen by the client.
>
> Parameters (All are optional):
> Level: The GZip Compression Level, 0 is lowest
> compression
> (biggest size, least processor usage),
> 9 is highest compression (smallest size,
> greatest
> processor usage)
> Unique: If you'd prefer something more unique than a
> second
> random number for tempfiles, specify it here
> Make sure the contents of the variable are all
> valid
> in a filename.
>
> CopyLeft 2000 Zachary Bedell <[EMAIL PROTECTED]>
>
> You may use this code as you wish provided I retain credit in
> the
> comments or elsewhere.
>
> No Warrenty. If it breaks, you get to keep both pieces....
> -ZSB 18-Dec-2000
> --->
> <cfif ThisTag.ExecutionMode EQ "END">
> <!--- Sane defaults: --->
> <cfparam name="Attributes.Level" default="9">
> <cfparam name="Attributes.Unique"
> default="#RandRange(1,10000000)#">
>
> <!--- Setup path & filename for tempfiles: --->
> <cfset RawHTMLFile =
> "c:\Temp\Compress\#Cgi.Script_Name#_#Attributes.Unique#_#RandR
> ange(1,100
> 0000
> )#.out">
> <cfset GZippedFile =
> "c:\Temp\Compress#Cgi.Script_Name#_#Attributes.Unique#_#RandRa
> nge(1,1000
> 000)
> #.in">
>
> <!--- Grab the generated content and write it out to a tempfile.
> --->
> <cfset Content = Trim(ThisTag.GeneratedContent)>
> <cffile action="WRITE" file="#RawHTMLFile#" output="#Content#">
>
> <!--- Compress the tempfile to another tempfile --->
> <cfx_GZip action="GZIP" InFile="#RawHTMLFile#"
> OutFile="#GZippedFile#" level="#Attributes.Level#">
> <cffile action="delete" file="#RawHTMLFile#">
>
> <!--- Setup the headers and write the mess back out to the
> client w/
> CFCONTENT --->
> <cfset ThisTag.GeneratedContent = "">
> <cfheader name="Content-Encoding" value="gzip">
> <cfcontent file="#GZippedFile#" deletefile="Yes"
> type="text/html">
> </cfif>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists