1

We have an application where angular is used in the frontend. Whenever we do the deployments, some of the functionalities are not working properly until we clear the complete cache in the browser. We knew it this is happening due to cache. Is there any way to fix this issue? We need as soon as they reload the page after the deployment, it should work. Especially in MAC, we are facing the issue frequently as they do not switch off their system & close the browser.

Any help would be appreciated.

Update 1: Angular generates the files with different hash on every build, but still we face this issue.

Also we tried adding these codes in index.html. But nothing helped us to resolve this issue.

<meta http-equiv="Cache-Control" content="no-cache, no-store,must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
Ramarasu R
  • 55
  • 5
  • Have you tried `--output-hashing=all` when building? – Harun Yilmaz May 04 '22 at 09:36
  • Yes, I have tried it. It did not help. – Ramarasu R May 04 '22 at 09:40
  • Did you setup your server to allow cache busting ? You should serve your `index.html` file in this way, otherwise indeed, you will have cachinh issues. Look into the `eTag` header. –  May 04 '22 at 09:47
  • https://stackoverflow.com/questions/55402751/angular-app-has-to-clear-cache-after-new-deployment according to this it now reads "ng build --prod --aot --outputHashing=all" – endlacer May 04 '22 at 09:56

1 Answers1

0

I was working under big project (3 years of develop from with 3 people). We fixed what with using gulp (for prepare env file setting with timestamp when prod was prepared and version.json file with current actual). So in production each 5 minutes front try to upload file and check curreant real version with current front version and if current front +new Date() < +new Date() (from version.json) we show dialog to user "we have new realse! Do u want reload page now or u will do it leater?" and call page refresh. After refresh front version will be same with version.json