4

I have an Angular / Web Api 2 site that uses ui-router for SPA behaviour and gulp for file transformations.

There is an issue where when I release the site, the user has to refresh their browser to view new content (usually). I have cache busting implemented on my js / css files, but it seems that the HTML views themselves are a problem. At the same time I can't help feel like I'm missing something blatantly obvious here.

How do I get my tech stack to refresh the user's content (eg. when adding a new field to an existing form) so that the user receives the most up to date version of the site after release?

  • Did you try using versioned query parameters? Described here: stackoverflow.com/a/119056/4495081. The example is for a script, but it should work for html just as well. – Dan Cornilescu Nov 15 '17 at 17:13
  • @Dan yep, I'm using gulp cache busting to generate a hash for my scripts & css files. Ex. npmjs.com/package/gulp-cache-buster – RandomUs1r Nov 15 '17 at 18:15
  • Exactly, IMHO you could use the same technique, except with a version # which you maintain as you wish - for example changing it only when you add a field to the respective form. – Dan Cornilescu Nov 15 '17 at 18:43
  • @Dan it sounds like I should introduce versioning and version detection via gulp / angular js then. I also really like alexcxe's idea of prompting the user to refresh rather than forcing it. – RandomUs1r Nov 15 '17 at 22:43
4

Here is what works for us.

We have a "version" file deployed with the application itself. Then, application issues a "check version" request periodically that checks if the version that the application has initially loaded is different from the version specified in this version file. If it is different, we show a notification that there is a new version available and suggest to refresh the browser window to get it.

I think that's what Google Inbox, for example, does. They have this periodic checkJsVersion request and, if there is a newer version of the web app available, they show this information box on the bottom left with a "New version is available, hit Refresh to get it" button.

There is also a different approach when the information about a new version of the app is pushed from the server to the client.

  • Makes sense, I'm going to give it a try, I also really like the idea of prompting the user to refresh when they're at a good stopping point. – RandomUs1r Nov 15 '17 at 22:44

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.