Optimizing Movable Type's Standard Templates for Speed (part 1)

| 1 Comment | No TrackBacks
Overall, Movable Type has some pretty decent standard templates.  Optimized for SEO, standardized class names and IDs, nicely separated in modules...  There is some learning involved if you want to understand all the conditional stuff that is going on under the hood, but once you know what you are doing they are quite easy to maintain and customize.  Not to mention the styles that are already available.
But if you install Movable Type out of the box and pick the standard, 'Classic' blog design using the default settings, you are not actually using the full power of Movable Type.  There are several settings you can change that will make publication of your blog (a lot) faster.

First tip: 'Manual' publishing mode

By default, all templates in a standard Movable Type blog are set to be published 'statically'.  This means that at publication time static HTML (or other) files are written to disk.  Publication is done by the actual CGI script that gets the publication request: most of the time this is mt.cgi, but sometimes also mt-comments.cgi, mt-tb.cgi or mt-cp.cgi (for comments, trackbacks and 'community' contributions).

Whenever something needs to be published in Movable Type, all 'index' templates are published again, along with some archive templates.  Generally this is a good idea: when a new entry comes in, you want to update the entry that contains the new comment but also the main page (to update the comment count) and various archives (for the same reason).  You might even want to update your RSS feed.

But do you really want to update the javascript file of your blog, a file listing some API endpoints, or the stylesheet of your blog?  No?  Tough luck, because Movable Type is publishing them again anyway, just because they are index templates set to 'static' publishing.  Each time you hit that 'Publish' button, you are publishing three files that basically never change.  Seems like a waste, no?

Fortunately, there is an easy fix: go to the screen listing your blog's templates.  

indextemplates.jpg

Open following templates, one by one:
  • Javascript
  • RSD
  • Stylesheet
For each of these templates, click 'Template Options' at the bottom and set the publication mode to 'Manually', then save.

manually.jpg

What did you just do?

From now on, these templates will never be published to a file unless you explicitly hit the 'Publish' option for that particular template.  So you are still free to tweak your stylesheet as desired, you just won't be republishing your changed file over and over again anymore in the future.

Hooray, you just shaved half a second off the publication time of each entry, comment or trackback.  It might not seem like much, but when you start getting thousands of comments a day, this sort of thing really starts to count...

(Why are these files set to 'static' publication anyway?)

You might be wondering why these files are set to 'static' publication to begin with?  Wouldn't it be much easier to just set them to 'manually' by default? If all users of Movable Type were experts, this would indeed be the preferable solution.  But since this is not the case, the current situation is probably preferable.

Why?  Imagine you are a novice user setting up your first MT blog.  Imagine you just set up everything (keeping the defaults), wrote your first entry and hit 'Publish'.  Next, you go to look at your blog.  What do you see?  An ugly, unstyled page (remember, no stylesheet) with a broken comments form (no javascript file...).  Not the ideal first impression...

Now if only there was a 'Publish once, then revert to manually' setting...

...hmm, good idea for a feature request :-)

UPDATE: Here is part 2 of this series.  

No TrackBacks

TrackBack URL: http://www.movabletips.com/cgi-bin/mt/mt-tb.cgi/26

1 Comment

Thanks for good tune of my MT blog. ;)

Leave a comment