The URL is timestamped to avoid caching problems when requesting the current path again

The URL is timestamped to avoid caching problems when requesting the current path again

1. Explanation: adding a timestamp to the URL will ensure that every request initiated is different from the previous request, so as to avoid the browser caching the URL.

2. Introduce the following code in HTML head:

<script type="text/javascript">
var timeTag = sessionStorage.getItem("time") || null;  
if(!timeTag) {  //Determine if there is a timestamp in sessionStorage, if not, add a timestamp to the url and save it
var arr = location.href.split('#/');
var timestamp = new Date().getTime(); //get the timestamp of the entry item
if( location.href.indexOf('?time=') ! = -1 ){ //judge sessionStorage did not save the timestamp, but the url has a timestamp case, you need to convert the url's timestamp to the latest, to avoid the cache of the current path again request
var arr2 = location.href.split('?time=');
window.location.href = arr2[0] + '?time=' + timestamp + '#/' +arr[1];
}else { //judge sessionStorage did not save the timestamp, and the url does not have a timestamp case, timestamp added to the url
window.location.href = arr[0] + '?time=' + timestamp + '#/' +arr[1];
}
sessionStorage.setItem("time",timestamp) // store the timestamp of the current entry item
}
</script>


Read More: