<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Simon Whatley &#187; bandwidth</title>
	<atom:link href="http://www.simonwhatley.co.uk/tag/bandwidth/feed" rel="self" type="application/rss+xml" />
	<link>http://www.simonwhatley.co.uk</link>
	<description>The opposite of every great idea is another great idea</description>
	<lastBuildDate>Wed, 02 Nov 2011 09:28:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Eliminating Whitespace in ColdFusion</title>
		<link>http://www.simonwhatley.co.uk/eliminating-whitespace-in-coldfusion</link>
		<comments>http://www.simonwhatley.co.uk/eliminating-whitespace-in-coldfusion#comments</comments>
		<pubDate>Fri, 26 Oct 2007 09:29:35 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Application Servers]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdFusion Administrator]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[page processing]]></category>
		<category><![CDATA[servlets]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[WAP]]></category>
		<category><![CDATA[web application]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[WEB-INF folder]]></category>
		<category><![CDATA[WEB-INF/lib folder]]></category>
		<category><![CDATA[web.xml]]></category>
		<category><![CDATA[web.xml file]]></category>
		<category><![CDATA[whitespace]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=351</guid>
		<description><![CDATA[ColdFusion has never satisfactorily removed whitespace from generated content, however, removing this whitespace can dramatically improve your website's performance. Take a 100KB page for example. If 20% of the page is made up of whitespace, that is 20% that is unneccessary and 20% bandwidth cost that can be saved.]]></description>
			<content:encoded><![CDATA[<p>ColdFusion has never satisfactorily removed whitespace from generated content, however, removing this whitespace can dramatically improve your website&#8217;s performance. Take a 100KB page for example. If 20% of the page is made up of whitespace, that is 20% that is unneccessary and 20% bandwidth cost that can be saved.</p>
<p>Currently there are two main ways a ColdFusion developer can prevent whitespace; via the ColdFusion Administrator and by including certain tags in their code:</p>
<p><strong>1. ColdFusion Administrator</strong></p>
<p>Under the <em>Server Settings &gt; Settings</em> menu item there is a checkbox called &#8216;Enable Whitespace Management&#8217;. This checkbox should always be checked. According to the description, checking this checkbox <em>&#8220;reduces the file size of the pages that ColdFusion returns to the browser by removing many of the extra spaces, tabs, and carriage returns that ColdFusion might otherwise persist from the CFML source file.&#8221;</em> I am yet to be convinced, but it is worthwhile enabling it.</p>
<p><strong>2. ColdFusion Tags</strong></p>
<p><code>&lt;cfsetting enablecfoutputonly="true"&gt;&lt;/cfsetting&gt;</code></p>
<p>The <code>cfsetting</code> tag controls aspects of page processing, such as the output of <acronym title="HyperText Markup Language">HTML</acronym> code in pages (inside and outside the <code>cfsetting</code> tag body). If <code>enablecfoutputonly</code> is set to <code>true</code>, <acronym title="HyperText Markup Language">HTML</acronym> output is blocked if it is not wrapped in a <code>cfoutput</code> tag. Therefore, this tag &#8216;can&#8217; be used to minimise the amount of generated whitespace.</p>
<p><code>&lt;cfsilent&gt;&lt;/cfsilent&gt;</code></p>
<p>The <code>cfsilent</code> tag supresses output produced by <acronym title="ColdFusion Markup Language">CFML</acronym> within a tag&#8217;s scope. Therefore, you simply need to wrap the tag around anything you don&#8217;t want to output to the browser. As it does not return anything from with in it, so you have to be a little be careful when debugging.</p>
<p><code>&lt;cfprocessingdirective supresswhitespace="true"&gt;&lt;/cfprocessingdirective&gt;</code></p>
<p>One of the <code>cfprocessingdirective</code>&#8216;s purposes is to remove excess whitespace from ColdFusion generated content in the tag body. However, it does not affect any whitespace in <acronym title="HyperText Markup Language">HTML</acronym> code. You can nest the tags and toggle <code>supresswhitespace</code> on and off, not that I ever identify a good reason to do so.</p>
<p><strong>But there is a little known third way, using a servlet filter called Trim Filter.</strong></p>
<p>Servlet filters are tools available to web application developers. They are designed to be able to manipulate a request and response (or both) that is sent to a web application.</p>
<p>Trim Filter lets you decrease the size of file your server will send to all clients. The filter removes extra spaces and line breaks from outputted documents. This can be especially useful for <acronym title="Wireless Application Protocol">WAP</acronym>/<acronym title="Wireless Markup Language">WML</acronym> developers working with mobile devices, where the size for transferred documents is limited.</p>
<p>S<strong>etting up the servlet filter in ColdFusion</strong></p>
<p>Using the Trim Filter servlet filter found at the following URL:</p>
<p><a rel="nofollow" href="http://www.servletsuite.com/servlets/trimflt.htm" title="TrimFilter jar File">http://www.servletsuite.com/servlets/trimflt.htm</a></p>
<ul>
<li>Download the <a rel="nofollow" href="http://www.servletsuite.com/servlets/trimflt.jar" title="trimflt.jar">trimflt.jar</a></li>
<li>Save trimflt.jar in the WEB-INF/lib folder in the ColdFusion Server wwwroot.</li>
<li>Edit the web.xml file in the WEB-INF folder in the ColdFusion Server wwwroot with the following code:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;filter-mapping&gt;
	&lt;filter-name&gt;trimFilter&lt;/filter-name&gt;
	&lt;url-pattern&gt;*.cfm&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
&nbsp;
&lt;filter&gt;
	&lt;filter-name&gt;trimFilter&lt;/filter-name&gt;
	&lt;filter-class&gt;com.cj.trim.trimFilter&lt;/filter-class&gt;
&lt;/filter&gt;</pre></div></div>

<ul>
<li>Restart the ColdFusion Service</li>
</ul>
<p>And now, when a ColdFusion page is invoked, the whitespace is suppressed and wow does it do a good job.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/eliminating-whitespace-in-coldfusion/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

