middleman/middleman — pull request #269 by bhollis (2012-02-11 18:24:11+00:00)
Title: Extension to add hash values to asset filenames

This extension causes asset file types (images, scripts, stylesheets, etc) to have a unique identifier appended to their filename that consists of a hash of their contents. This allows for serving them with a far-future Expires header, while generating a unique filename when the asset changes. It is superior to the `cache_buster` extension in that it doesn't rely on query string (which some proxy caches and browsers don't consider) and its unique-ifier is more stable than the mtime of the file.

This extension also includes a Rack middleware that rewrites references to these assets in HTML, JavaScript, and CSS files, eliminating the need to use special helper functions to include modified filenames in references.

This pull request is missing tests! Tests must be created that exercise the feature in both the preview server and build, across HTML, JavaScript, and CSS files. There are also several other scenarios that should be tested:
* This extension on at the same time as `:relative_assets` is on.
* This extension running on files that use the Padrino asset helpers (image_tag, stylesheet_link_tag, etc) or Compass/SASS helpers (image_url, spriting, etc).
* The above scenarios should be tried with and without an asset host specified. (Ideally, the filenames would still be rewritten even with an asset_host set since that's generally used for some sort of CDN, but I don't think it handles that right now).

Once this extension is tested, landed, and tried out in a few sites, the `cache_buster` extension should be deleted.