0

I have deployed my angular cli app through VSTS using automated build process. However I am facing js file caching problem. I have to refresh page for every deployment to see new changes. Please help me to solve this problem.

Thank You,

CHEEKATLAPRADEEP-MSFT
  • 9,245
  • 1
  • 10
  • 31
  • if you change the deployed version how do you expect it to get your changes if you dont do some form of refresh? magic? – WhatsThePoint Nov 29 '17 at 13:14
  • Now browser uses files from cache, it does not load from server. As a client perspective pressing ctrl + r is not a solution. – Pankaj Dhote Nov 29 '17 at 13:34

1 Answers1

0

It is cached by internet browser, not related to the deployment process or web services.

You can add ?version to the link, such as <script type="text/javascript" src="myfile.js?1500"></script>, you can change the version if the js file is changed.

A related thread: How can I force clients to refresh JavaScript files?

starian chen-MSFT
  • 31,056
  • 2
  • 22
  • 47
  • 1
    Thank You for Your response. Yes I have done the same thing which you just explained above. I want to confirm, is it a best way to do cache busting? Because whenever user is going to login in application, browser will fetch all the js files which has different version number. but then I have some big js files its near about 2.5 mb. So it takes time to load. – Pankaj Dhote Dec 01 '17 at 07:09
  • If the js file isn't changed, you don't need to change the version and the cached file will be used if the file has been cached by internet browser. In other words, for static files, the internet browser is based on the URL to cache files, if reference url is changed, then it will load the new one. – starian chen-MSFT Dec 01 '17 at 07:58
  • Note: We're seeing index.html not being updated in the Azure DevOps Build Pipeline, likely due to the fact that the cache busting code generation doesn't know that the files have changed since every build is from scratch. – Joshua Drake Jan 28 '19 at 21:46