Introduce `bundle_name` setting #15

Merged
merged 1 commit into from May 24, 2014

Conversation

Projects
None yet
2 participants
Contributor

NV commented Sep 1, 2013

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.

@NV NV Introduce `bundle_name` setting
A classic approach to handling 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 that a have a website with 100 HTML pages. All of them include js like so:

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

When we change JS, 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.
ba3a29d
Owner

moshen commented Oct 7, 2013

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.

moshen added the enhancement label May 24, 2014

@moshen moshen merged commit ba3a29d into moshen:master May 24, 2014

@moshen moshen added a commit that referenced this pull request May 24, 2014

@moshen moshen Merge remote-tracking branch 'issue_15/bundle_name'
Resolves #15
f74ef40

@moshen moshen added a commit that referenced this pull request May 24, 2014

@moshen moshen Clean up #15 bundle_name, docs 496bdde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment