views:

102

answers:

4

Hello, I have a problem with a page that includes two js files. In firebug it shows that every time the page loads those two files get included with the prefix ?_=someRandomNumber

I don't know where that random number is generated from and I guess it is the reason the files are not being cached and are downloaded each time the page is hit.

Here is the firebug snapshot

GET http://127.0.0.1:8500/file1.js?_=1251379620583
GET http://127.0.0.1:8500/file2.js?_=1251379620583

200 OK
 697ms jquery-1....2.min.js (line 19)
GET http://127.0.0.1:8500/file1.js?_=1251379622773
GET http://127.0.0.1:8500/file2.js?_=1251379622773

200 OK
 148ms

My include is very simple

<script type="text/javascript" src="file1.js"></script>
 <script type="text/javascript" src="file2.js"></script>

I am also using jQuery in the application.

Thanks!

+1  A: 

It looks like current timestamp (or file's timestamp) and is most likely there to make sure the file is not cached.

Michael Krelin - hacker
+1  A: 

This won't be a javascript issue, the source of this behaviour will be in whatever server-side technology you're using to generate the page.

nickf
A: 

Yes, the random number there is precisely to prevent your browser from caching the files. This is the general technique used when the developers have a resource which they keep updating and want the updates to be reflected.

Crimson
A: 

Firebug is a developer tool, aiding development. It makes sure that any changes you make to a file aren't cached so that a new copy is requested everytime. If it didn't request a new version, and kept requesting an old version. Old buggy versions of code could be laoded as opposed to a new, bugless version.

dotty
That does not seem to be the case. FB does not handle caching, it is done by the browser. FB will only show me what is going on. In this case it shows that these files are downloaded every time the page is called even tough it would show that they are not being downloaded if I move them to a different directory.