expalmer/metalsmith-gist — pull request #2 by sukima (2014-10-14 16:33:28+00:00)
Title: Add support to cache gists from the network

With a fresh run on my [website][1] the two bottle necks to building were the gist plugin and the templates plugin. Realizing the real slow down in the gist plugin was the many network requests needed (one per gist in the blog).

This patch add caching by saving the response JSON from the server into a `.gists/` folder. It uses MD5 to sanitize the filename (since a gist has slashs and other non-filename characters in it).

This can be turned off with the `caching: false` option.

Benchmarks
----------

Initial run (no cache): 1359ms Second run (with cache): 9ms

Obviously the caveats are:

1. The user needs to put the cache directory in their `.gitignore`. The directory can be set via the `cacheDir` option that defauts to `.gists`.
2. If the gists are updated on github then the cache needs to be cleared to get the update. `rm -rf .gists/`

[1]: http://tritarget.org/