3

I saw the code as below in a html file. It appears like passing into the app.js a value as v=$appVersion

  <script>document.write("<script type='text/javascript' src='resources/js/app.js?v=" + appVersion + "'><\/script>");</script>

However, I did not find a global variable "v" in app.js. Curious what does this line do...

1
  • 4
    this is likely a cache busting technique at play. Commented Feb 5, 2020 at 4:38

2 Answers 2

3

This is for cachebusting. The v=1231231 makes the script url unique, so that when a new version is released, the url changes, and the browser requests the new version instead of using the old cached one.

Sign up to request clarification or add additional context in comments.

Comments

0

If you add query parameters to any URL, the browser considers it as a different URL. You can fool the browser in case you need to circumvent caching.

If some URL has failed or blocked, adding query parameters to the URL will force the browser to retry the request for the same resource. Adding some random query parameters is mostly harmless unless of course if the same query parameter is being used or verified by the server/host/API you're hitting.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.