moshen / jekyll-asset_bundler

A small plugin for Jekyll to easily bundle and compress site assets
MIT License
101 stars 21 forks source link

Introduce `bundle_name` setting #15

Closed NV closed 10 years ago

NV commented 11 years ago

A classical approach to JS/CSS bundles is to use a hash of the file content as a filename and attach 'Cache-Control: max-age=31556900' or 'Expires' HTTP header.

Now imagine a website with 100 HTML pages. All of them include js like so:

<script scr="95a78b02de98.js"></script>

When JS changes, the hash of the file changes too, causing all HTML files that uses that JS to change as well.

One solution to this problem would be to stop using hashes as filenames.

I use bundle_name option on n12v.com where PJAX is used heavily. JS doesn’t get requested when user navigates between pages but HTML does. It makes more sense to don’t use MD5 hashes for bundle names.

moshen commented 11 years ago

If you use a static name, wouldn't this cause someone loading the page to continue to use their cached version, thereby not loading your changes? Are you implying that the static bundle_name would be combined with an earlier Cache-Control timeout to ensure that client caches are empty in time to receive site updates?

I agree with your analysis that when one uses file hashes as file names, it requires rewriting all files. Though, I don't think it's a big deal. Also, on my sites I have a matching expiry for all content to ensure a full client refresh when it drops out of cache.

I'm not saying I'm completely opposed to this PR, just a little puzzled by it.