micromata / Baumeister

Unmaintained – :construction_worker: The aim of this project is to help you to build your things. From Bootstrap themes over static websites to single page applications.
MIT License
171 stars 37 forks source link

Switch from revisioning files via query param to filenames for cachebusting #231

Closed mischah closed 6 years ago

mischah commented 6 years ago

Hej,

until now we added a query string to compiled files to make sure the won’t be served from the browser cache like:

<script src="app/polyfills.bundle.min.js?rev=@@hash"></script>

Based on a very old article this approach is pretty much abandoned and the de facto standard is to use hashes as part of the filename. See Googles perf tipps and Webpacks caching guide for example.

<script src="app/polyfills.bundle.[hash].js"></script>

Main advantage

Every browser and proxy sees these files as new ones and won’t serve them from cache.

Possible disadvantage

There will be new version which every build and this would would »spam« the dist directory if its added to version control. But I question that anyone would to this these days?

Possible solution: Add a property named useCachBusting to baumeister.json to be able to switch of cache busting.


Can I get a 👍 / 👎 for switching to dynamic filenames for cachebusting?

krnlde commented 6 years ago

If the dist/ is needed to be checked in to version control, the problem will be a spammed folder. Each commit will have a deleted (old) hashed version and a new one, no merge conflicts though, since the hash is unique to its content.

mischah commented 6 years ago

If the dist/ is needed to be checked in to version control, the problem will be a spammed folder. Each commit will have a deleted (old) hashed version and a new one, no merge conflicts though, since the hash is unique to its content.

Thanks. Updated the issue with corrected info.

mischah commented 6 years ago

Done for v3 in webpack branch for now.