<?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>Experiment, Adopt, Achieve &#187; code</title>
	<atom:link href="http://www.markgibaud.com/blog/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markgibaud.com/blog</link>
	<description>On Innovation in Software Engineering</description>
	<lastBuildDate>Sun, 20 Nov 2011 20:45:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Solution to Combine, Minify and GZIP your JS and CSS</title>
		<link>http://www.markgibaud.com/blog/2009/06/26/solution-to-combine-minify-and-gzip-your-js-and-css/</link>
		<comments>http://www.markgibaud.com/blog/2009/06/26/solution-to-combine-minify-and-gzip-your-js-and-css/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 12:05:02 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.markgibaud.com/blog/?p=22</guid>
		<description><![CDATA[I've recently completed a fair bit of research and consequent development at work that goes quite far to improve the performance of our web application's front-end. I thought I'd share the basic solution here. The first obvious thing to do is benchmark your site using Yahoo's YSlow and Google's PageSpeed. These will highlight the &#34;low-hanging [...]]]></description>
			<content:encoded><![CDATA[<p>I've recently completed a fair bit of research and consequent development at work that goes quite far to improve the performance of our web application's front-end. I thought I'd share the basic solution here.</p>
<p>The first obvious thing to do is benchmark your site using Yahoo's YSlow and Google's PageSpeed. These will highlight the &quot;low-hanging fruit&quot; performance improvements to make. Unless you've already done so, the resulting suggestions will almost certainly include combining, minifying and gzipping your static content.</p>
<p>The steps we're going to perform are:</p>
<ol>
<li>Write a custom HTTPHandler to combine and minify CSS. </li>
<li>Write a custom HTTPHandler to combine and minify JS. </li>
<li>Include a mechanism to ensure that the above only do their magic when the application is not in debug mode. </li>
<li>Write a custom server-side web control to easily maintain css/js file inclusion. </li>
<li>Enable GZIP of certain content types on IIS 6. </li>
</ol>
<p>Right, let's start with CSSHandler.asax that implements the .NET IHttpHandler interface:</p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.IO;
<span style="color: blue">using </span>System.Text;
<span style="color: blue">using </span>System.Web;

<span style="color: blue">namespace </span>WebApplication1
{
    <span style="color: blue">public class </span><span style="color: #2b91af">CssHandler </span>: <span style="color: #2b91af">IHttpHandler
    </span>{
        <span style="color: blue">public bool </span>IsReusable { <span style="color: blue">get </span>{ <span style="color: blue">return true</span>; } }

        <span style="color: blue">public void </span>ProcessRequest(<span style="color: #2b91af">HttpContext </span>context)
        {
            <span style="color: blue">string</span>[] cssFiles = context.Request.QueryString[<span style="color: #a31515">&quot;cssfiles&quot;</span>].Split(<span style="color: #a31515">','</span>);

            <span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt; files = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt;();
            <span style="color: #2b91af">StringBuilder </span>response = <span style="color: blue">new </span><span style="color: #2b91af">StringBuilder</span>();
            <span style="color: blue">foreach </span>(<span style="color: blue">string </span>cssFile <span style="color: blue">in </span>cssFiles)
            {
                <span style="color: blue">if </span>(!cssFile.EndsWith(<span style="color: #a31515">&quot;.css&quot;</span>, <span style="color: #2b91af">StringComparison</span>.OrdinalIgnoreCase))
                {
                    <span style="color: green">//log custom exception
                    </span>context.Response.StatusCode = 403;
                    <span style="color: blue">return</span>;
                }

                <span style="color: blue">try
                </span>{
                    <span style="color: blue">string </span>filePath = context.Server.MapPath(cssFile);
                    <span style="color: blue">string </span>css = <span style="color: #2b91af">File</span>.ReadAllText(filePath);
                    <span style="color: blue">string </span>compressedCss = Yahoo.Yui.Compressor.<span style="color: #2b91af">CssCompressor</span>.Compress(css);
                    response.Append(compressedCss);
                }
                <span style="color: blue">catch </span>(<span style="color: #2b91af">Exception </span>ex)
                {
                    <span style="color: green">//log exception
                    </span>context.Response.StatusCode = 500;
                    <span style="color: blue">return</span>;
                }
            }

            context.Response.Write(response.ToString());

            <span style="color: blue">string </span>version = <span style="color: #a31515">&quot;1.0&quot;</span>; <span style="color: green">//your dynamic version number 

            </span>context.Response.ContentType = <span style="color: #a31515">&quot;text/css&quot;</span>;
            context.Response.AddFileDependencies(files.ToArray());
            <span style="color: #2b91af">HttpCachePolicy </span>cache = context.Response.Cache;
            cache.SetCacheability(<span style="color: #2b91af">HttpCacheability</span>.Public);
            cache.VaryByParams[<span style="color: #a31515">&quot;cssfiles&quot;</span>] = <span style="color: blue">true</span>;
            cache.SetETag(version);
            cache.SetLastModifiedFromFileDependencies();
            cache.SetMaxAge(<span style="color: #2b91af">TimeSpan</span>.FromDays(14));
            cache.SetRevalidation(<span style="color: #2b91af">HttpCacheRevalidation</span>.AllCaches);
        }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Ok, now some explanation:</p>
</p>
<p>IsReUsable property:</p>
<p>We aren't dealing with anything instance-specific, which means we can safely reuse the same instance of the handler to deal with multiple requests, because our ProcessRequest is threadsafe. <a href="http://neilkilbride.blogspot.com/2008/01/ihttphandler-isreusable-property.html">More info</a>.</p>
<p>ProcessRequest method:</p>
<p>Nothing too hectic going on here. We're looping through the CSS files given to us (see the CSSControl below for how they're coming in) and compressing each one, using a .NET port of Yahoo's YUICompressor, before adding the contents to the outgoing response stream.</p>
<p>The remainder of the method deals with setting up some HTTP caching properties to further optimise the way the browser client downloads (or not, as the case may be) content.</p>
<ul>
<li>We set Etags in code so that they may be the same across all machines in our server farm. </li>
<li>We set Response and Cache dependencies on our actual files so, should they be replaced, cache will be invalidated. </li>
<li>We set Cacheability such that proxies can cache. </li>
<li>We VaryByParams using our <em>cssfiles</em> attribute, so that we can cache per CSS file group submitted through the handler. </li>
</ul>
<p>And here is the CSSControl, a custom server-side control inheriting the .NET LiteralControl.</p>
<p>Front:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">customcontrols</span><span style="color: blue">:</span><span style="color: #a31515">csscontrol </span><span style="color: red">id</span><span style="color: blue">=&quot;cssControl&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;&gt;
          &lt;</span><span style="color: #a31515">CustomControls</span><span style="color: blue">:</span><span style="color: #a31515">Stylesheet </span><span style="color: red">File</span><span style="color: blue">=&quot;main.css&quot; /&gt;
          &lt;</span><span style="color: #a31515">CustomControls</span><span style="color: blue">:</span><span style="color: #a31515">Stylesheet </span><span style="color: red">File</span><span style="color: blue">=&quot;layout.css&quot; /&gt;
          &lt;</span><span style="color: #a31515">CustomControls</span><span style="color: blue">:</span><span style="color: #a31515">Stylesheet </span><span style="color: red">File</span><span style="color: blue">=&quot;formatting.css&quot; /&gt;
&lt;/</span><span style="color: #a31515">customcontrols</span><span style="color: blue">:</span><span style="color: #a31515">csscontrol</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Back: </p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.ComponentModel;
<span style="color: blue">using </span>System.Web;
<span style="color: blue">using </span>System.Web.UI;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>TTC.iTropics.Utilities;

<span style="color: blue">namespace </span>WebApplication1
{
    [<span style="color: #2b91af">DefaultProperty</span>(<span style="color: #a31515">&quot;Stylesheets&quot;</span>)]
    [<span style="color: #2b91af">ParseChildren</span>(<span style="color: blue">true</span>, <span style="color: #a31515">&quot;Stylesheets&quot;</span>)]
    <span style="color: blue">public class </span><span style="color: #2b91af">CssControl </span>: <span style="color: #2b91af">LiteralControl
    </span>{
        [<span style="color: #2b91af">PersistenceMode</span>(<span style="color: #2b91af">PersistenceMode</span>.InnerDefaultProperty)]
        <span style="color: blue">public </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Stylesheet</span>&gt; Stylesheets { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }

        <span style="color: blue">public </span>CssControl()
        {
            Stylesheets = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Stylesheet</span>&gt;();
        }

        <span style="color: blue">protected override void </span>Render(<span style="color: #2b91af">HtmlTextWriter </span>output)
        {
            <span style="color: blue">if </span>(<span style="color: #2b91af">HttpContext</span>.Current.IsDebuggingEnabled)
            {
                <span style="color: blue">const string </span>format = <span style="color: #a31515">&quot;&lt;link rel=\&quot;Stylesheet\&quot; href=\&quot;stylesheets/{0}\&quot;&gt;&lt;/link&gt;&quot;</span>;

                <span style="color: blue">foreach </span>(<span style="color: #2b91af">Stylesheet </span>sheet <span style="color: blue">in </span>Stylesheets)
                    output.Write(format, sheet.File);
            }
            <span style="color: blue">else
            </span>{
                <span style="color: blue">const string </span>format = <span style="color: #a31515">&quot;&lt;link type=\&quot;text/css\&quot; rel=\&quot;Stylesheet\&quot; href=\&quot;stylesheets/CssHandler.ashx?cssfiles={0}&amp;version={1}\&quot;/&gt;&quot;</span>;
                <span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: blue">string</span>&gt; stylesheetsArray = Stylesheets.Select(s =&gt; s.File);
                <span style="color: blue">string </span>stylesheets = <span style="color: #2b91af">String</span>.Join(<span style="color: #a31515">&quot;,&quot;</span>, stylesheetsArray.ToArray());
                <span style="color: blue">string </span>version = <span style="color: #a31515">&quot;1.00&quot; </span><span style="color: green">//your version number

                </span>output.Write(format, stylesheets, version);
            }

        }
    }

    <span style="color: blue">public class </span><span style="color: #2b91af">Stylesheet
    </span>{
        <span style="color: blue">public string </span>File { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>HttpContext.Current.IsDebuggingEnabled is hooked up to the following setting in your web.config: </p>
<p></p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">compilation </span><span style="color: red">debug</span><span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;<span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>So, basically, if your site is in debug mode you get HTML markup like this: </p>
<p></p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">link </span><span style="color: red">rel</span><span style="color: blue">=&quot;Stylesheet&quot; </span><span style="color: red">href</span><span style="color: blue">=&quot;stylesheets/formatting.css&quot;&gt;&lt;/</span><span style="color: #a31515">link</span><span style="color: blue">&gt;
&lt;</span><span style="color: #a31515">link </span><span style="color: red">rel</span><span style="color: blue">=&quot;Stylesheet&quot; </span><span style="color: red">href</span><span style="color: blue">=&quot;stylesheets/layout.css&quot;&gt;&lt;/</span><span style="color: #a31515">link
</span><span style="color: blue">&lt;</span><span style="color: #a31515">link </span><span style="color: red">rel</span><span style="color: blue">=&quot;Stylesheet&quot; </span><span style="color: red">href</span><span style="color: blue">=&quot;stylesheets/main.css&quot;&gt;&lt;/</span><span style="color: #a31515">link</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>But if you're in production mode (debug=false), you'll get markup like this: </p>
<p></p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">link </span><span style="color: red">type</span><span style="color: blue">=&quot;text/css&quot; </span><span style="color: red">rel</span><span style="color: blue">=&quot;Stylesheet&quot; </span><span style="color: red">href</span><span style="color: blue">=&quot;CssHandler.ashx?cssfiles=main.css,layout.css,formatting.css&amp;version=1.0&quot;/&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The latter will then obviously invoke the CSSHandler, which will take care of combining, minifying and cache-readying your static CSS content. </p>
<p>All of the above can then also be duplicated for your static JavaScript content:</p>
<p>`JSHandler.ashx:</p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.IO;
<span style="color: blue">using </span>System.Text;
<span style="color: blue">using </span>System.Web;

<span style="color: blue">namespace </span>WebApplication1
{
    <span style="color: blue">public class </span><span style="color: #2b91af">JSHandler </span>: <span style="color: #2b91af">IHttpHandler
    </span>{
        <span style="color: blue">public bool </span>IsReusable { <span style="color: blue">get </span>{ <span style="color: blue">return true</span>; } }

        <span style="color: blue">public void </span>ProcessRequest(<span style="color: #2b91af">HttpContext </span>context)
        {
            <span style="color: blue">string</span>[] jsFiles = context.Request.QueryString[<span style="color: #a31515">&quot;jsfiles&quot;</span>].Split(<span style="color: #a31515">','</span>);

            <span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt; files = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: blue">string</span>&gt;();
            <span style="color: #2b91af">StringBuilder </span>response = <span style="color: blue">new </span><span style="color: #2b91af">StringBuilder</span>();

            <span style="color: blue">foreach </span>(<span style="color: blue">string </span>jsFile <span style="color: blue">in </span>jsFiles)
            {
                <span style="color: blue">if </span>(!jsFile.EndsWith(<span style="color: #a31515">&quot;.js&quot;</span>, <span style="color: #2b91af">StringComparison</span>.OrdinalIgnoreCase))
                {
                    <span style="color: green">//log custom exception
                    </span>context.Response.StatusCode = 403;
                    <span style="color: blue">return</span>;
                }

                <span style="color: blue">try
                </span>{
                    <span style="color: blue">string </span>filePath = context.Server.MapPath(jsFile);
                    <span style="color: blue">string </span>js = <span style="color: #2b91af">File</span>.ReadAllText(filePath);
                    <span style="color: blue">string </span>compressedJS = Yahoo.Yui.Compressor.<span style="color: #2b91af">JavaScriptCompressor</span>.Compress(js);
                    response.Append(compressedJS);
                }
                <span style="color: blue">catch </span>(<span style="color: #2b91af">Exception </span>ex)
                {
                    <span style="color: green">//log exception
                    </span>context.Response.StatusCode = 500;
                    <span style="color: blue">return</span>;
                }
            }

            context.Response.Write(response.ToString());

            <span style="color: blue">string </span>version = <span style="color: #a31515">&quot;1.0&quot;</span>; <span style="color: green">//your dynamic version number here

            </span>context.Response.ContentType = <span style="color: #a31515">&quot;application/javascript&quot;</span>;
            context.Response.AddFileDependencies(files.ToArray());
            <span style="color: #2b91af">HttpCachePolicy </span>cache = context.Response.Cache;
            cache.SetCacheability(<span style="color: #2b91af">HttpCacheability</span>.Public);
            cache.VaryByParams[<span style="color: #a31515">&quot;jsfiles&quot;</span>] = <span style="color: blue">true</span>;
            cache.VaryByParams[<span style="color: #a31515">&quot;version&quot;</span>] = <span style="color: blue">true</span>;
            cache.SetETag(version);
            cache.SetLastModifiedFromFileDependencies();
            cache.SetMaxAge(<span style="color: #2b91af">TimeSpan</span>.FromDays(14));
            cache.SetRevalidation(<span style="color: #2b91af">HttpCacheRevalidation</span>.AllCaches);
        }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And its accompanying JSControl: </p>
<p>Front:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">customcontrols</span><span style="color: blue">:</span><span style="color: #a31515">JSControl </span><span style="color: red">ID</span><span style="color: blue">=&quot;jsControl&quot; </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;&gt;
    &lt;</span><span style="color: #a31515">customcontrols</span><span style="color: blue">:</span><span style="color: #a31515">Script </span><span style="color: red">File</span><span style="color: blue">=&quot;jquery/jquery-1.3.2.js&quot; /&gt;
    &lt;</span><span style="color: #a31515">customcontrols</span><span style="color: blue">:</span><span style="color: #a31515">Script </span><span style="color: red">File</span><span style="color: blue">=&quot;main.js&quot; /&gt;
    &lt;</span><span style="color: #a31515">customcontrols</span><span style="color: blue">:</span><span style="color: #a31515">Script </span><span style="color: red">File</span><span style="color: blue">=&quot;creditcardpayments.js&quot; /&gt;
&lt;/</span><span style="color: #a31515">customcontrols</span><span style="color: blue">:</span><span style="color: #a31515">JSControl</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Back: </p>
<p></p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.ComponentModel;
<span style="color: blue">using </span>System.Web;
<span style="color: blue">using </span>System.Web.UI;
<span style="color: blue">using </span>System.Linq;

<span style="color: blue">namespace </span>WebApplication1
{
    [<span style="color: #2b91af">DefaultProperty</span>(<span style="color: #a31515">&quot;Scripts&quot;</span>)]
    [<span style="color: #2b91af">ParseChildren</span>(<span style="color: blue">true</span>, <span style="color: #a31515">&quot;Scripts&quot;</span>)]
    <span style="color: blue">public class </span><span style="color: #2b91af">JSControl </span>: <span style="color: #2b91af">LiteralControl
    </span>{
        [<span style="color: #2b91af">PersistenceMode</span>(<span style="color: #2b91af">PersistenceMode</span>.InnerDefaultProperty)]
        <span style="color: blue">public </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Script</span>&gt; Scripts { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }

        <span style="color: blue">public </span>JSControl()
        {
            Scripts = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Script</span>&gt;();
        }

        <span style="color: blue">protected override void </span>Render(<span style="color: #2b91af">HtmlTextWriter </span>writer)
        {
            <span style="color: blue">if </span>(<span style="color: #2b91af">HttpContext</span>.Current.IsDebuggingEnabled)
            {
                <span style="color: blue">const string </span>format = <span style="color: #a31515">&quot;&lt;script src=\&quot;scripts\\{0}\&quot;&gt;&lt;/script&gt;&quot;</span>;

                <span style="color: blue">foreach </span>(<span style="color: #2b91af">Script </span>script <span style="color: blue">in </span>Scripts)
                    writer.Write(format, script.File);
            }
            <span style="color: blue">else
            </span>{
                <span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: blue">string</span>&gt; scriptsArray = Scripts.Select(s =&gt; s.File);
                <span style="color: blue">string </span>scripts = <span style="color: #2b91af">String</span>.Join(<span style="color: #a31515">&quot;,&quot;</span>, scriptsArray.ToArray());
                <span style="color: blue">string </span>version = <span style="color: #a31515">&quot;1.0&quot; </span><span style="color: green">//your dynamic version number
                </span><span style="color: blue">const string </span>format = <span style="color: #a31515">&quot;&lt;script src=\&quot;scripts/JsHandler.ashx?jsfiles={0}&amp;version={1}\&quot;&gt;&lt;/script&gt;&quot;</span>;

                writer.Write(format, scripts, version);
            }
        }
    }

    <span style="color: blue">public class </span><span style="color: #2b91af">Script
    </span>{
        <span style="color: blue">public string </span>File { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Enabling GZIP: </p>
<p>As Jeff Atwood <a href="http://www.codinghorror.com/blog/archives/000059.html">says</a>, enabling Gzip on your web site server is a no-brainer. After some tracing, I decided to enable Gzip on the following file types:</p>
<ul>
<li>.css </li>
<li>.js </li>
<li>.axd (Microsoft Javascript files) </li>
<li>.aspx (Usual ASP.NET Web Forms content) </li>
<li>.ashx (Our handlers) </li>
</ul>
<p>To enable HTTP Compression on your IIS 6.0 web server:</p>
<ol>
<li>Open IIS, Right click Web Sites, Services tab, enable <strong>Compress Application Files</strong> and <strong>Compress Static Files</strong> </li>
<li>Stop IIS </li>
<li>Open up IIS Metabase in Notepad (C:\WINDOWS\system32\inetsrv\MetaBase.xml) - and make a back up if you're nervous about these things <img src='http://www.markgibaud.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </li>
<li>Locate and overwrite the two <strong>IIsCompressionScheme</strong> and one <strong>IIsCompressionSchemes</strong> elements with the following: </li>
</ol>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">IIsCompressionScheme    </span><span style="color: red">Location </span><span style="color: blue">=</span>&quot;<span style="color: blue">/LM/W3SVC/Filters/Compression/deflate</span>&quot;
        <span style="color: red">HcCompressionDll</span><span style="color: blue">=</span>&quot;<span style="color: blue">%windir%\system32\inetsrv\gzip.dll</span>&quot;
        <span style="color: red">HcCreateFlags</span><span style="color: blue">=</span>&quot;<span style="color: blue">0</span>&quot;
        <span style="color: red">HcDoDynamicCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcDoOnDemandCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcDoStaticCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcDynamicCompressionLevel</span><span style="color: blue">=</span>&quot;<span style="color: blue">9</span>&quot;
        <span style="color: red">HcFileExtensions</span><span style="color: blue">=</span>&quot;<span style="color: blue">htm
            html
            txt
            css</span>&quot;
        <span style="color: red">HcOnDemandCompLevel</span><span style="color: blue">=</span>&quot;<span style="color: blue">9</span>&quot;
        <span style="color: red">HcPriority</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot;
        <span style="color: red">HcScriptFileExtensions</span><span style="color: blue">=</span>&quot;<span style="color: blue">asp
            dll
            exe
            aspx
            js
            ashx
            axd</span>&quot;
    <span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">IIsCompressionScheme</span><span style="color: blue">&gt;
&lt;</span><span style="color: #a31515">IIsCompressionScheme    </span><span style="color: red">Location </span><span style="color: blue">=</span>&quot;<span style="color: blue">/LM/W3SVC/Filters/Compression/gzip</span>&quot;
        <span style="color: red">HcCompressionDll</span><span style="color: blue">=</span>&quot;<span style="color: blue">%windir%\system32\inetsrv\gzip.dll</span>&quot;
        <span style="color: red">HcCreateFlags</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot;
        <span style="color: red">HcDoDynamicCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcDoOnDemandCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcDoStaticCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcDynamicCompressionLevel</span><span style="color: blue">=</span>&quot;<span style="color: blue">9</span>&quot;
        <span style="color: red">HcFileExtensions</span><span style="color: blue">=</span>&quot;<span style="color: blue">htm
            html
            txt
            css</span>&quot;
        <span style="color: red">HcOnDemandCompLevel</span><span style="color: blue">=</span>&quot;<span style="color: blue">9</span>&quot;
        <span style="color: red">HcPriority</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot;
        <span style="color: red">HcScriptFileExtensions</span><span style="color: blue">=</span>&quot;<span style="color: blue">asp
            dll
            exe
            aspx
            js
            ashx
            axd</span>&quot;
    <span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">IIsCompressionScheme</span><span style="color: blue">&gt;
&lt;</span><span style="color: #a31515">IIsCompressionSchemes    </span><span style="color: red">Location </span><span style="color: blue">=</span>&quot;<span style="color: blue">/LM/W3SVC/Filters/Compression/Parameters</span>&quot;
        <span style="color: red">HcCacheControlHeader</span><span style="color: blue">=</span>&quot;<span style="color: blue">max-age=86400</span>&quot;
        <span style="color: red">HcCompressionBufferSize</span><span style="color: blue">=</span>&quot;<span style="color: blue">8192</span>&quot;
        <span style="color: red">HcCompressionDirectory</span><span style="color: blue">=</span>&quot;<span style="color: blue">%windir%\IIS Temporary Compressed Files</span>&quot;
        <span style="color: red">HcDoDiskSpaceLimiting</span><span style="color: blue">=</span>&quot;<span style="color: blue">FALSE</span>&quot;
        <span style="color: red">HcDoDynamicCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcDoOnDemandCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcDoStaticCompression</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
        <span style="color: red">HcExpiresHeader</span><span style="color: blue">=</span>&quot;<span style="color: blue">Wed, 01 Jan 1997 12:00:00 GMT</span>&quot;
        <span style="color: red">HcFilesDeletedPerDiskFree</span><span style="color: blue">=</span>&quot;<span style="color: blue">256</span>&quot;
        <span style="color: red">HcIoBufferSize</span><span style="color: blue">=</span>&quot;<span style="color: blue">8192</span>&quot;
        <span style="color: red">HcMaxDiskSpaceUsage</span><span style="color: blue">=</span>&quot;<span style="color: blue">99614720</span>&quot;
        <span style="color: red">HcMaxQueueLength</span><span style="color: blue">=</span>&quot;<span style="color: blue">1000</span>&quot;
        <span style="color: red">HcMinFileSizeForComp</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot;
        <span style="color: red">HcNoCompressionForHttp10</span><span style="color: blue">=</span>&quot;<span style="color: blue">FALSE</span>&quot;
        <span style="color: red">HcNoCompressionForProxies</span><span style="color: blue">=</span>&quot;<span style="color: blue">FALSE</span>&quot;
        <span style="color: red">HcNoCompressionForRange</span><span style="color: blue">=</span>&quot;<span style="color: blue">FALSE</span>&quot;
        <span style="color: red">HcSendCacheHeaders</span><span style="color: blue">=</span>&quot;<span style="color: blue">FALSE</span>&quot;
    <span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And that's it! This saved us heaps of bandwidth and resulted in a more responsive web application throughout. </p>
<p>Enjoy!</p>
<div class="shr-publisher-22"></div>]]></content:encoded>
			<wfw:commentRss>http://www.markgibaud.com/blog/2009/06/26/solution-to-combine-minify-and-gzip-your-js-and-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

