Closed mikevaux closed 7 years ago
Would something like this be an option for you?
https://www.npmjs.com/package/gulp-rev/
Static asset revisioning by appending content hash to filenames: unicorn.css => unicorn-d41d8cd98f.css
Thanks for the reply!
I'm not sure; we already use something like that as part of the build process (https://www.npmjs.com/package/gulp-cachebust) to simultaneously revision the file names, and the references to them in the templates. (This happens directly after useref()
is called.) So, e.g.
/src/css/main.css
becomes /dist/css/main.1a2b3c4d.css
<link rel="stylesheet" href="src/css/main.css">
becomes <link rel="stylesheet" href="src/css/main.1a2b3c4d.css">
I'm just trying to get my head round how this sort of system (or at least the gulp-rev
alternative) could work well for cache busting in local development. We use twig to render the templates, so my best guess from a fairly quick look through the docs would be that we would need to write some sort of micro plugin for the CMS to get the rev'd references from the manifest.json
file. We'd then need to swap out gulp-useref
altogether for e.g. gulp-concat
, which presumably gulp-rev
is aware of (in terms of bundling & file names changing). Is that roughly the sort of thing you were thinking?
I would look for some alternative to using a query string during local development. That seems unnecessary to me. If it's because of the .htaccess file, that should be on your production server only I would think.
Ok, sure, makes sense. Agreed that the query string seems unnecessary, I guess it's just a way which I've been using which works ;)
Thanks so much for the responses!
Firstly, thanks so much for maintaining this really useful repository!
I have noticed that assets with query strings don't get bundled.
Consider:
Part 1 gets processed,
dist/css/main.css
gets created, the reference in thedist
template file is written correctly, butpart-2.css
's contents are missing fromdist/css/main.css
If it is just one file:
Then the reference in the
dist
template is still written correctly, but nodist/css/main.css
gets created.The reason I am looking to use a query string in local development is to append the current timestamp to always cachebust the file whilst keeping the .htaccess expires headers version controlled. (If that's bad practise or there's a better I'm happy to be advised!)
Hopefully I'm not missing anything, but I couldn't see anything when searching for 'query' in the docs and in both open and closed issues.
Shout if you need any more info! :)