jpcache with Movable Type

I’m again using jpcache with my blog. This time however, I’ve integrated the PHP-based gzip and caching capabilities of jpcache with Movable Type.

You should see a significant speed improvement through out the site — especially on some of the longer category pages.

It was fairly easy to incorporate into MT since I’m already outputting PHP files from my MT templates. Basically, after following the uncomplicated install guide for jpcache and running a few sample test pages, all I needed to do was “prepend” the jpcache script to the end of my PHP files.

You can do this by adding a require(‘/path/to/jpcache.php’) to your MT templates and rebuilding them as PHP scripts.

Or simply create an “.htaccess” file at the root of your blog directory and add the php directive “auto_prepend_file”, which will append the specified file to the end of every PHP script within your blog directory (this includes sub-directories).

For example:

php_value auto_prepend_file /path/to/jpcache/jpcache.php

So far, I’ve found only a few downsides however…

Since files are cached for 15 minutes by default you will not see updates reflected on the site until the cached file expires. Of course the cache expiration is configurable and in fact you can turn it off entirely, so it’s not a show-stopper for me and I’m happy with the outcome.

Ultimately however, I like to be using the Smarty Template Engine, which Brad Chocate integrated with Movable Type, but for basic file caching and gzip compression, jpcache suited me well.