Search code examples
javascriptincludesrc

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?


Solution

  • 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.