Reputation: 2413
SCENARIO:
I am trying to come up with a way to Version Control in JS that fulfills two premises:
Therefore I came up with this scheme:
I need FE to reload contents everytime a new version is available, so a simple way to achieve this would be to add a version tag to src link:
<script type="text/javascript" src="myfile.js?15.6.0"></script>
I can add some templating, so the version number can be defined elsewhere, like:
<script type="text/javascript" src="myfile.js?$$RELEASE_ID$$"></script>
PROBLEM:
I would need to call the Backend, to know the latest version (and the Backend will read it from pom.xml
file, returning it afterwards)
QUESTION:
Is there any way I can use so the Front End knows what is the latest version?
Thanks.
Upvotes: 9
Views: 2620
Reputation: 1832
I'd use buildnumber-maven-plugin to generate a version tag, e.g. git hash. And, embed it somewhere in a war file. Either
See https://github.com/renfeng/event-manager/blob/master/pom.xml#L130-L155
Upvotes: 2
Reputation: 1137
There is no way to eliminate communication with back end in order to get information about a state of a file on the server. But if you desire to have as few requests as possible, you could set an intervals for your FE to poll the server.
If you usually release BE version every day, it makes since to poll server any change every 12, 6 ,4 or any number of hours you want. It all depends on how crucial it is to update the file.
That been said, in most cases when updating a file version on back end, once page is refreshed (which is likely to happen after few hours) the server will send the new file version, unless server caching strategy is configured otherwise.
Upvotes: 1