• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 836
  • Last Modified:

Single Page Application how to detect when new version is on server, if so refresh cache

Have a single page application that needs to refresh the users browser cache when a newer version is present on the server.

What needs to be done to detect a new version on the server and then what needs to be done in the code to force a refresh?

Thanks.

jquery, Hot Tub, breeze
0
Black_Trash
Asked:
Black_Trash
  • 2
1 Solution
 
GaryCommented:
I suppose you could add an hidden field to the page containing a 'version'
On page load make an ajax request to your server for the current version and if different run

location.reload(true); // same as an hard refresh
0
 
Black_TrashAuthor Commented:
Gary,
  Thanks for posting the response..

Question within the SPA where do you thing a good place to insert the code:
"location.reload(true);"
at.

  Also when you refer to "location"  not sure what does.

Thanks,
Keith
0
 
GaryCommented:
Are you using jquery or vanilla javascript?
It would be placed before the closing body tag as you would need for the page to 'load' before you could check if the version field was cached.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now