I am building a Multilingual / Multi-locale site.  The most effective way I
have found to do this is to pregenerate versions of each page for each
locale and each language.  The involves a simple publishing system that
glues various components together and writes out multiple versions of each
page, which are included in a wrapper script at run time.

As an afterthought, I added a final step where the publishing script
replaces ALL multiple whitespaces (tabs, CR, LF, space) with a single space.
This means much smaller pages without any overhead ... and bemused looks
from people who "view source" on the site!  Of course this function can be
toggled to enable HTML debugging.  

The only place I have found this causing probles is with HTML comments
inside Javascripts.  So I simply added a final step to place a carriage
return after each HTML comment in the final output that is written to file.


This way I get to use nice formatting and indenting for HTML, SQL, etc, but
the final file size is crunched to the bare minimum.... dropped 100k off
larger pages.

-Rob

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 01, 2001 9:53 AM
To: CF-Talk
Subject: RE: Statistics on Toy R Us



Ah... the Evil Whitespace...

All CFSETTING does is remove any white space that "CF puts in".  If you love
indented web pages and use this extensively for your HTML, CF didn't put it
in, YOU DID.  If, however, a CF tag, once processed, would introduce space,
CF will do string processing to remove the space from the page.  If you do a
lot of this in your page, stripping some of the empty space could make a
difference, especially if you have 30+ lines of query statements, CFPARAMs,
etc. at the top of every page.  If your pages are fairly light on CF but
have tons of tabs, CFSETTING won't really help you.

So why bother using CFSETTING at all?  Well, if you have a ton of CF code
throughout your site, especially CFOUTPUTs utilizing queries or CFLOOPs, you
are actually creating lots of activity in these parts of your page and white
space may occur as a result.  Removing this on complex pages or those with a
lot of data, may very well shrink your web pages by a large amount.  If so,
ON THOSE PAGES, you should consider removing white space.

Consider also what you'd ask CF to do if you asked it to remove absolutely
every instance of tabs, extra spaces, etc.  You'd be doing the equivalent of
a REPLACE function which is a string operation, arguably the slowest
possible operation a language undertakes (if you rule out external accesses
to slow systems - CFHTTP for example).  This could dramatically impact your
CPU.

The CF Admin remove whitespace function essentially is the same thing as
putting CFSETTING at the beginning of EVERY page in your server.

Allaire recommends that you NOT do this because, let's face it, not all of
your pages are going to benefit from having the white space removed.  So, if
you tell CF to remove white space from ALL of your pages, it's doing a lot
of extra work for little or no benefit in most cases.

So what's the best approach?  My suggestion is to run a page, do a
Properties check on it to see how big the resulting file is.  Save that file
to your PC and then do a manual search/replace on all tabs and double spaces
(not singles or sentences will be affected).  Save the file and see how much
smaller it is.  If it's 1-2k you might not want to worry about it depending
on your server's capacity and how busy your site is.  If, however, the
difference is several k, you might want to tune this page up because
multiplied by thousands of page views, you're wasting megabytes of bandwidth
and causing users to wait even longer for the rest of your site to start
downloading.

That's my two cents... I hope it helps.

--Doug
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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

Reply via email to