The "--outputHashing=all" option changes the name of my files to bust the cache. This is not a great option for me. Can I get this feature to append a query string parameter (like "?v=hash"), instead of renaming the file? If output hashing won't do this, are there other easy ways to achieve this?
1 Answer
That would require support beyond Angular. The query string is handled by the web server, so you would need to modify the web server so that it handles the query string.
I doubt there's built-in support for anything like that in the web servers. You'd need to write some kind of script that maps the query string to wherever the actual files are. Which means you'd probably need to adjust your deployment procedure to deploy each version in, for example, a different directory, and then the query parameter is used to identify the actual directory from which to serve the files, for example.
And even so, you might need to manually edit the files (such as index.html) to reference the file with a query hash.
This seems like an XY problem (https://en.wikipedia.org/wiki/XY_problem). Perhaps you can describe the problem you're facing with filename-based hashing and someone might be able to offer some solutions for that.
2 Comments
ng build are all referencing the correctly named file, you just need to serve all the files.