0

I have a website developed in AngularJS, and index.html serves the root of the application.

All the JS and CSS versions are maintained in the index.html itself, which means for any changes to reflect to the user, "index.html" is to be reloaded at the browser.(correct me if I am wrong here). This is a problem, since there could be chances that the user has a tab opened of our website in his browser and we have published a new release. This release will not be published at user's browser till the time a "Manual refresh" is not triggered and "index.html" is not reloaded and hence bring up the possibility that the user will not be using our latest release.

We have written a framework to reload all resources once a release is detected by sending the latest version from web-server and comparing this with the current version in the browser and trigger a reload automatically. This fix works fine, but the problem again is, how to publish this release first time to all user's browser?

I hope you get my problem? let me know otherwise.

  • If your clients have the website open all the time in the browser, there is no way to control what it does if you didn't implement something before hand to handle this situation. Tell them to refresh the page and let your framework to deal with it next time there is a change in the resources. – Omri Luzon Feb 18 '17 at 11:51
  • @ Omri Luzon: Thanks for the update. This is definitely my last option, just wanted to see if there exists a possiblity to handle this? Btw I am using Nginx as my web server. Is there anything that can be configured at Nginx to achieve this? – Karan Malhotra Feb 18 '17 at 12:06
  • Not something general that I know of, It looks like it should be something specific to your application. – Omri Luzon Feb 18 '17 at 12:08

1 Answers1

1

This is not possible. There is no way to force an open page to refresh if it does not already have code to implement that feature. You will have to wait until the user refreshes it themselves, and the browser cache expires, and any intermediate caches between the user and your servers.

I recommend searching to learn about "HTTP caching" if you are not already familiar, as well as "cache busting." In general, you may want to consider making index.html a small file that references your big files in <script> tags, setting the cache control for index.html very low, and use cache busting techniques on your big files.

But for your first release, there is no way to invalidate open tabs or existing caches. If this will cause a problem with your server, read up on "API versioning" for different ways to handle it.

Eric Simonton
  • 5,702
  • 2
  • 37
  • 54