Read more

Middleman does not fingerprint asset paths by default

Henning Koch
August 11, 2016Software engineer at makandra GmbH

We're using Middleman Show archive.org snapshot for some static sites like our blog Show archive.org snapshot .

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Despite being very similar to Rails, Middleman does not add a fingerprint hash to its asset paths by default. This means that when you write this:

<%= javascript_include_tag 'all.js' %>

... you always get the same path, regardless of the contents of all.js:

<script src='/javascripts/all.js'>

Because browsers tend to cache assets for a while, this means that users might not get your changes until their cache expires.

You can fix this by adding (or uncommenting) this in config.rb:

configure :build do
  activate :asset_hash
end

This will give your asset paths fingerprints:

<script src='/javascripts/all-3e02c23b.js'>

Note that the built files will now only include the fingerprinted version. There won't be an all.js anymore. So make sure to use helpers when refering to asset paths.

Posted by Henning Koch to makandra dev (2016-08-11 11:33)