Jump to the post that solved this thread.
Solved: 3 Years, 2 Months ago Whats the purpose of query strings on javascript?
#2
Solved: 3 Years, 2 Months ago
You can drop it for sure and it will work as intended.
The reason it is appended there is to handle browser cache. Sometimes the browser keeps the cached resources and upon same request returns the resource from cache instead of repeatedly downloading it from the source to optimize bandwidth and page load time.

This can lead to the problem as say if you have the general.js cached by the browser in v. 1.8.15 and you have been upgraded to v. 1.8.17. Now say there is a big change in general.js in 1.8.17 upgrade. What the browser get is a request to include general.js from the same source defined earlier. Browser has no clue that the current resource has been changed with the upgrade and returns the resource from the cache which is actually a copy of general.js that was included with 1.8.15 and hence the resource doesn't contain the updated code. This can break your site / lead to unintended behavior. Appending the version differs the resource ink from earlier so browser now knows that this is a different resource from it was earlier, hence re-downloads and re-caches it. Thus you always get the latest resource included in your page avoiding the said issue.

The good practice is to include the file hash instead of version in query string as the hash gets changed only if the file is changed. But for us this suffice the purpose as it is now.
Reply
Jump to the post that solved this thread.


Messages In This Thread
RE: Whats the purpose of query strings on javascript? - by effone - 2018-08-21, 09:47 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)