Wednesday, August 17, 2011

Hosting favicon.ico on a different server (Amazon S3)

To increase the performance of our very simple Where is Croydon test site static assets are hosted on S3.

One of the assets that is requested for a site is favicon.ico the icon is used against the site name in browsers (normally to make spotting it among many tabs easier). By default this is requested from the root of the site, however this can be changed by adding:
<link rel="shortcut icon" href="" />
to each page (head element) on the site.

To host it on S3 requires a bucket matching the domain name, and mapping a CNAME to point to the amazon end-point. In this case using a "static" sub-domain to host these kinds of static assets. Note: if you get "Access Denied" from these its probably because of permissions for "Everyone" to open/download are not set (per asset).

Doing this means the browser can use a separate connection to retrieve the icon, and therefore process the download in parallel with other content. Its worth considering multiple sub-domains if you have many static assets. This also has the benefit of reducing requests to your site's servers, and improving server-side cache hits as well.

During testing of this a little "feature" of chrome was discovered, it requests "/favicon.ico" from you site if you do a "view page source" - even if you specify a different location.

No comments: