tdreyno/middleman — Issue #174: Consider Sprockets hashed filenames during build
Author: tdreyno
Created: 2011-11-30 07:41:04+00:00
State: open

Sprockets has the ability to rename files to include a timestamp of their last computed change. This allows caching services which ignore query strings (used by the cache_buster feature) to cache files.

There are a handful of issues.

1. Timestamps need to be against files in source, not build. Cache buster also has this problem. Files/Assets are copied into the build folder on build, which gives an erroneous modified date. The "real" modified date is that of the file in source/

2. The asset_url helper needs to be overwritten to write out newly hashed paths in build mode. Using the helpers will be required to use this feature (image_tag, javascript_include_tag, etc).

3. Should integrate with "middleman build --clean" which removes unused files. Generating hashed file names will create lots of extra files over time. We need to be able to clean them up.

It MIGHT be better to implement this hashing ourselves in the cache_buster feature. Simply copy all assets on build, rename them with the current timestamp and overwrite asset_url. Might actually be simpler than integrating with Sprockets.