Image Caching in wanderer

After having spent a few weeks now working on this site (and site generator), I came to realize a few things:

  1. It’s really, really nice to be able to edit your tools as you learn things about your workflow
  2. I was rebuilding images way too often.

For #2, I had originally a stopgap ‘fix’ in place by ensuring that the wanderer program typically only rebuilt files that had changed since the last run, ensuring images and old documents wouldn’t be redundantly built. However, as the feature set expanded, this also became unwieldy; older pages that had feeds or links to other pages might need to be automatically updated. Updates to the wanderer tool would require a full site rebuild. If I changed the global template, that’d also trigger a full rebuild.

And images would always take a good half a minute to build – which seemed terribly wasteful considering that they almost never changed after the initial image was saved.

The solution, then, was to separate content and media building: Instead of copying images directly to the build folder, I now build them into the cache folder, and then copy the cached, processed image into build if the cached image is newer than the source image. This way, even if the build folder is destroyed and has to be regenerated, we can still pull images from the cache.

In the end, it’s not really a deep technical change, and mostly is just an organizational step, but it’s already made a huge difference in my daily development.