Not a developer? Go to

Plugin and Theme Directory

CacheBlock v1.0

By Mark Carey
Posted January 21, 2008, in Developer.


CacheBlock is a plugin that can dramatically speed up publishing by caching blocks of built template code. CacheBlock is very flexible, enabling you to cache an entire page, a small template snippet, a template module, a sidebar widget, and entire sidebar, etc. Each block can be set to expire after a certain duration -- some blocks you may want to cache for 5 minutes, others for hours, or even days. When used wisely, the result is significantly faster publishing times and faster comment-posting.

For each page that is published by Movable Type, a large number of template tags are evaluated by the system, which often requires many database lookups. The CacheBlock plugin strives to reduce those database lookups by caching groups of template code that has already been evaluated. For example, suppose you decided to cache your entire sidebar. The first time MT publishes that sidebar, it will do many database lookups to generate lists of recent entries, comments, lists of archives and tags, etc. After that, the CacheBlock plugin will take all of that sidebar HTML and save it in the cache. The next time MT needs to publish your sidebar, it will find it in the cache, so it will skip the evaluation and related database lookups for the entire sidebar, and simply fetch the pre-built sidebar from the cache. This can speed up the process a lot. Imagine if you are trying to publish a 1000 page site, and each of those pages includes the sidebar!

Behind the scenes, CacheBlock checks to see if memcached is available and enabled. If it is, CacheBlock will stores blocks using memcached, which is very fast. BUT, you don't need to have memcached! If memcached is not available, CacheBlock will simply store the block in the database. As such, it will still require a database lookup to retrieve it from the cache, but you can save dozens or even hundreds of database lookups by caching significant segments of built template code, by replacing them with a single lookup to the cache. Even without memcached, CacheBlock can dramatically speed up publishing.


Movable Type versions: 4.3