Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript Source Query

While browsing the code of some websites I sometimes notice that some JavaScript files are included like this:

  <script type="text/javascript" src="javascripts/jquery.js?1252521516"></script>

But I don't see what the jquery.js ?1252521516 part of the src parameter does. Can anyone explain this to me please?

like image 866
James Brooks Avatar asked Dec 01 '25 09:12

James Brooks


2 Answers

It allows websites to force browsers to update their cached version of a script or other resource.

For example, when the Javascript code on that website changes, the number at the end would be changed. The browser would see as a totally new file, meaning it would not use whatever outdated, cached version it had previously downloaded. This gives you all the benefits of caching with the ability to bypass the cached version at any time.

like image 74
William Brendel Avatar answered Dec 03 '25 23:12

William Brendel


It's known as a cache breaker. It stops the browser using an old version of your javascript due to caching rules.

like image 32
robertc Avatar answered Dec 04 '25 01:12

robertc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!