3

I have seen some source code, use this:

<script src="js/script.js?07457154"></script>

4 Answers4

4

This is one of ways to avoid browser or server caching the result of request by this URL.

Sergey Kudriavtsev
  • 10,328
  • 4
  • 43
  • 68
1

It's a random number to prevent browser to read javascript file from cache. By this number, browser thinks it's a different script and interprets it again instead of reading from the cache.

It doesn't have to be a number. It may be any random value.

Aycan Yaşıt
  • 2,106
  • 4
  • 34
  • 40
1

This is the simple trick to avoid caching of javascript files.It is very helpful in the situation when your .js file is already cached & you want to reflect new changes quickly.

Look at below SO answer for few more tricks to do it.

How to force browser to reload cached CSS/JS files?

Community
  • 1
  • 1
metalfight - user868766
  • 2,722
  • 1
  • 16
  • 20
1

As it has already been pointed out in the comments, it's used to prevent a browser from caching Javascript files. The browser cannot be sure anymore that it is the same file and needs to handle is as it would be a completely different one.

The same principle applies for .css files as well. It is commonly used for different versions of frameworks when there are changes from one version to the other. In those cases the version might be added as a parameter.

A completely random number everytime is not a good idea though, because it might fill caches with the same content over and over again with different names.

noone
  • 19,520
  • 5
  • 61
  • 76