Speeding up BlogIt by caching files with ExpiresByType

The recent 1.4.0 version of BlogIt adds a bunch of user-interface fancies, and Ajax goodies. The cost of doing this was the addition of jQuery, jQuery-UI, and a couple of jQuery libraries, all weighing in at over 100k. Unfortunately, depending on how your host is configured, this might make BlogIt driven sites load a little slower.

One way to minimize the effect of this is to force your visitors browser to cache javascript, css, and image files, by adding future expiry headers. This won't affect the load speed the first time visitors hit your site, but it will help for subsequent loads by that visitor. If you host uses Apache, and have the mod_expires module loaded, then you can use the ExpiresByType directive to set an expiration date relative to the current date.

The example below goes into your .htaccess file, typically in public_html, and specifies that all javascript, css, and images should be cached for 1 month (2,592,000 seconds) after (the 'A') the user first accesses the files.

ExpiresActive on
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/ico A2592000

Note that one of the side effects of this is that if you change any of the files returning visitors are going to see the old files, until their cache expires, or until they do a 'force refresh', which they are unlikely to do. So, use this with caution, or reduce the cache time.