Make it possible to use file hashes in query strings instead of file name
See original GitHub issueClear and concise description of the problem
In our environment, there’s a specific whitelist for files permitted to be served. At the same time, I’d like to employ hashes to serve the most recent versions of the files.
I’d like to use hashes as query strings (eg. fileX.js?v=87654321
) instead of part of the file name (fileX.87654321.js
), as that won’t necessitate an update of the whitelist.
Updating the config with eg. build.rollupOptions.output.assetFileNames
to assets/[name].[ext]?v=[hash]
will just literally append ?v=87654321
to the actual file name.
Suggested solution
Config option (maybe it already exists in some form)
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Put the hash in the query part of the filename rather than ...
Concerning the contents of the script - there's no universal answer, as it depends on your build configuration (i.e. which files do you...
Read more >Adding Hashes to Filenames - SurviveJS
Cache invalidation can be achieved by including a hash to the filenames. Starting from version 5, webpack is using a deterministic way of...
Read more >Use a querystring hash to defeat cache instead of filename hash
I need to change the cachebusting from [name].[contenthash:8].css' to [name].css?[contenthash:8]' because of the way our deploys happen.
Read more >Query string hashing - Xperience 13 Documentation - Kentico
The hash function is calculated from the query string parameters using SHA-2. The hashing is used in various parts of the system: Dialogs...
Read more >Bust That Cache Through A Content Hash - Alain Schlesser
The query string appended to the end of the URL makes some proxy servers assume that the content of that file is dynamic...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bluwy Thanks for the input!
Absolutely agree with you, although what’s frustrating is that one doesn’t always have complete control over the deployment chain / environment policies.
Anyway, you’re right that this is the domain of a custom plugin, and it was really quite easy to implement once I did a bit more research:
vite.config.js
:…along with
Understood. I will comment again when I figure out the implementation. Thanks for the reply.