While easy, uploading an entire directory with a s3 cp –recursive doesn’t feel like the most efficient approach, and definitely won’t scale well. With a static site, there are at least two reasons to be precise in operating on files. The first is that a clearing the cache at your CDN could have a performance impact if you experience a high volume of traffic. This is not currently an issue for us at Geotrocities HQ, but it’s certainly good to plan for the future. The other issue with using the recursive cudgel is that every file is uploaded every time. For a large site, that could eat a lot of bandwidth, and take awhile to complete a relatively trivial change like adding a single article.

As I’m using make to automate management of the site, I’d like to make this process pretty automatic. Thinking about this, I can think of two primary ways to do this:

  1. Detection. Use a tool like find or stash the data from git to identify the files that changed
  2. Convention. Have the filenames and directory structure use a convention that makes it predictable

As I’ve thought about the problem, (1) has generally seems like the obvious approach. The data is all there. Finding and operating on files modified in the last hour or day using find is pretty easy, so that is a nice, straightforward approach with a few potential imperfections. Grabbing the files that git identifies as modified should also be pretty straightforward, and is likely to be more accurate than find, although I’m not sure it gains a lot. Turning to convention, at first glance it seemed to be tricky, as humans are involved, but perhaps there is opportunity to manage even more with make. For example, I was thinking that adding images would be tricky. But if I were to augment the Makefile to automate the adding of images with a new command, I would no longer need to remember various syntax. A command like make image article= image= would allow me to put the image file into an article-specific directory and append the markdown syntax for including the image directly to the article for easily including it in the post.

So, I’ve just about convinced myself that convention is ideal. It’s scriptable, it takes some remembering out of the picture, and it seems like fun.