Tapirtype Blog: Index

Programming Archives

September 7, 2007

A cache that stays...

Ok, I think I have the caching thing figured out. Seems that Smarty (which handles the dynamic publishing--and caching--for Movable Type) defaults to a one hour cache timeout. What Smarty does is write the time-stamp in a header on the cached file along with an expire time-stamp computed by adding an interval determined by the smarty variable $cache_lifetime which defaults to 3600 seconds (or one hour). When retrieving a page, smarty compares the expire time with the time the cached file was built and retrieves the cached file only when the cache has not yet expired.

Why it does this is another matter. One hour seems either far too long or far too short for the life of a cache. It especially makes no sense in the context of Movable Type which seems to clear the cache whenever there is a change to the database, such as saving an entry--whether or not the entry is published--or making a comment (although, not, for some reason, when comments are deleted). Incidentally, I haven't yet figured out how Movable Type achieves this. I can't seem to find where in the code it flushes the cache or checks the modification date on the database, however I have empirically determined that this is the behavior.

This caching behavior especially makes no sense for me, since this blog changes, at most, daily. Fortunately, the default cache lifetime can be changed by editing the smarty.class.php file (found at mt/php/extlib/smarty/libs/). At the top of the file, which defines the smarty class, a bunch of default values for variables are set, some of which are overridden by Movable Type when it creates an instance of the smarty object and uses it to display dynamic content, notably the $caching variable which defaults to 0 (off) is flipped on later if you have enabled caching enabled via publishing preferences.

Setting $cache_lifetime = -1 results in a cache that never expires until the Movable Type database is changed, the setting that makes sense (to me, anyway) assuming that the only way the content displayed for a given page will change is if a change is made through Movable Type. This does bring up an important caveat however (although one I haven't verified), which is that if you have dynamic content on a page that changes based on input other than the Movable Type database, it may not work, or may take some extra effort to ensure that it works.

September 13, 2006

Accessible Programming

I just came across an article in Salon titled “Why Johnny can't code” exploring the decline in availability of simple programming tools included with computers. It happens to be written by one of my faveorite Science Fiction authors, David Brin (a fact that I didn't realize until the mention of Startide Rising on the last page--bad me for not reading bylines). His basic thesis is that currently children (or students of any age) have no ready access to a simple programming language like the BASIC that used to be included with every computer, and that because of this, while computers are becoming more and more important, people have less and less of an inroad into understanding how they work.

Continue reading “Accessible Programming” »

You are visiting Tapirtype Blog. Unless otherwise noted, all content is © 2006-2008 by Sasha Kopf and Michael Boyle, some rights reserved. Site design by Michael Boyle modified from the standard Movable Type templates. I've made an attempt to generate standards compliant content which should look best in Safari or, otherwise, Firefox. Use of Internet Explorer may be harmful to your sanity and I've made little attempt to support it.

If you like you can subscribe to Tapirtype Blog's feed. That way you can be the first to know when more things burble from our brains.

This page is published using Movable Type 4.1