There is a popular question on how to force-clear the cache of the browser in a VanillaJS application, with the general consensus being, setting the name of the .js-script or the scripts arguments to a new value: Force browser to clear cache
How can I achieve this with Angular (currently 5.1 in AngularCLI/Webpack build), so every time I release the code in production (with AOT), a new version is built? I would use date-hashing instead of indexing, but the main question is: where can I set it (eg the script name/arguments)? In development, where the CLI takes care of rebuilding the app, this is not an issue, just in production!
There is a popular question on how to force-clear the cache of the browser in a VanillaJS application, with the general consensus being, setting the name of the .js-script or the scripts arguments to a new value: Force browser to clear cache
How can I achieve this with Angular (currently 5.1 in AngularCLI/Webpack build), so every time I release the code in production (with AOT), a new version is built? I would use date-hashing instead of indexing, but the main question is: where can I set it (eg the script name/arguments)? In development, where the CLI takes care of rebuilding the app, this is not an issue, just in production!
Share Improve this question asked Dec 14, 2017 at 14:55 PhilPhil 7,5669 gold badges54 silver badges95 bronze badges 1- This is i did for angular: stackoverflow.com/questions/55402751/… – Lejo Commented Apr 28, 2020 at 5:57
1 Answer
Reset to default 16By setting your build command to target production ng build --target=production
, the cli automatically hashes your js files. Here are the docs You can also set the command manually if you wanted it on dev ng build --output-hashing=all