KARPACH

WEB DEVELOPER BLOG

YSlow and ASP.NET: 100 points "A" grade year 2012

Almost three years ago I wrote an original YSlow and ASP.NET: 100 points “A” grade is possible article. Since then I changed a couple of hosting providers, made numerous updates and converted my blog project to .NET 4.0. Today I decided to revise my blog to see if it still has 100 yslow points with a final “A” grade.

The first surprise, as of January 29, 2012, YSlow addon doesn’t work in FireFox 9. However YSlow is now available for Google Chrome, Opera, Safari. It has bookmarket version and even command line version. I installed Google Chrome Yslow extension and began investigation. Right out of the box most of the sections still had an A grade. About a week ago I switched from Google App Engine “CDN” to true CDN Amazon CloudFront. Some files were not in CDN, so I had to take care of those. In general, I highly recommend Amazon CloudFront. It is easy to setup and costs just a few bucks a month based on your traffic usage. Amazon CloudFront mimics your local file settings, so you need to make sure that you have compression, expire header and Etags taken care of. I use IIS7 compression instead of a compression module recommended by me in my previous article. Out of the box IIS7 compression doesn’t work with AWS CloudFront, so you need to modify C:\Windows\System32\inetsrv\config\applicationHost.config file on your server to include the following:

    <serverRuntime enabled="true" frequentHitThreshold="1" frequentHitTimePeriod="00:00:20"/>

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" noCompressionForHttp10="False" noCompressionForProxies="False">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
      <dynamicTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </dynamicTypes>
      <staticTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </staticTypes>
    </httpCompression>

Also I modified my cache module to have ETags clean up:

    public void Init(HttpApplication context)
    {   
        ...                 
        context.PostReleaseRequestState += new EventHandler(application_PostReleaseRequestState);
    }

    void application_PostReleaseRequestState(object sender, EventArgs e)
    {
        HttpContext.Current.Response.Headers.Remove("Server");
        HttpContext.Current.Response.Headers.Remove("X-AspNet-Version");
        HttpContext.Current.Response.Headers.Remove("ETag");
    }

YSlow added a new section “Use Cookie-free Domains”. My blog completely failed this one, since google analytics left cookies in a top-level karpach.com domain. I modified google analytics init script to have: _gaq.push([’_setDomainName’, ‘www.karpach.com’]), so google cookies are set for www.karpach.com instead of a top-level karpach.com. Then subdomain cdn.karpach.com, which points to Amazon CloudFront, became cookieless. Finally, I am back to 100 YSlow points.

Posted on January 29, 2012 by