By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,598 Members | 1,894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,598 IT Pros & Developers. It's quick & easy.

Why using javascript version file

P: n/a
I noticed that some sites use <script
src='fineName.js?ver=XXX'></script(even google)
Someone told me that it's for script changes, means - if the file in
server has been changed than the new XXX will demand to load the new
file.
I find it hard to believe that it's true.
Any suggestions ?

Aug 26 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Ivo
<ro********@gmail.comschreef
some sites use <script src='fineName.js?ver=XXX'></script>
Someone told me that it's for script changes, means - if the file
in server has been changed than the new XXX will demand to
load the new file.
I find it hard to believe that it's true.
The URL as requested will show up in the server log, that in itself could be
reason enough to use this construct. Additionally, some serverside
functionality could be set up to deliver different files depending on the
URL, regardless of the extension. The filename extension means nothing if
you configure your server to deliver different content depending on the
search string, and send it with the appropriate "application/x-javascript"
content-type header. This is what Google and others are reported to be
doing. What else is there to believe?
Ivo
http://4umi.com/web/html/httpheaders.htm
Aug 26 '06 #2

P: n/a
wrote on 26 aug 2006 in comp.lang.javascript:
I noticed that some sites use <script
src='fineName.js?ver=XXX'></script(even google)
Someone told me that it's for script changes, means - if the file in
server has been changed than the new XXX will demand to load the new
file.
I find it hard to believe that it's true.
Any suggestions ?
The client cannot "know" the server has a changed file on its HD without
receiving info or the actual file from the server.

However the client [read: browser] sees different querystrings as diffeent
files, and will not take a different file from it's cache, but will sent
out for that new file.
http://aaa.ext/a.asp?a=3

and

http://aaa.ext/a.asp?a=11

are considered different.

So, why would it be hard to believe that:

fineName.js?ver=XXX

ant

fineName.js?ver=YYY

are not handled the same way?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 26 '06 #3

P: n/a
Thanks for your reply,

I made some tests for IE && FF (using http debuggers) and found that
the if script file has been changed then the browser will load the new
script. probably due to it's last modified time stamp.
So again, for that reason - there is no need to add ?ver=XXX.
So why using it ?

Evertjan. wrote:
wrote on 26 aug 2006 in comp.lang.javascript:
I noticed that some sites use <script
src='fineName.js?ver=XXX'></script(even google)
Someone told me that it's for script changes, means - if the file in
server has been changed than the new XXX will demand to load the new
file.
I find it hard to believe that it's true.
Any suggestions ?

The client cannot "know" the server has a changed file on its HD without
receiving info or the actual file from the server.

However the client [read: browser] sees different querystrings as diffeent
files, and will not take a different file from it's cache, but will sent
out for that new file.
http://aaa.ext/a.asp?a=3

and

http://aaa.ext/a.asp?a=11

are considered different.

So, why would it be hard to believe that:

fineName.js?ver=XXX

ant

fineName.js?ver=YYY

are not handled the same way?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 27 '06 #4

P: n/a
Thanks for your reply,

I aggree, for this kind of server side mechanism or server logs it's
make sense.
But why use it for script changes if its load the new script in any
case (due to the modified timestamp)?

Ivo wrote:
<ro********@gmail.comschreef
some sites use <script src='fineName.js?ver=XXX'></script>
Someone told me that it's for script changes, means - if the file
in server has been changed than the new XXX will demand to
load the new file.
I find it hard to believe that it's true.

The URL as requested will show up in the server log, that in itself could be
reason enough to use this construct. Additionally, some serverside
functionality could be set up to deliver different files depending on the
URL, regardless of the extension. The filename extension means nothing if
you configure your server to deliver different content depending on the
search string, and send it with the appropriate "application/x-javascript"
content-type header. This is what Google and others are reported to be
doing. What else is there to believe?
Ivo
http://4umi.com/web/html/httpheaders.htm
Aug 27 '06 #5

P: n/a
wrote on 27 aug 2006 in comp.lang.javascript:
Evertjan. wrote:
>wrote on 26 aug 2006 in comp.lang.javascript:
I noticed that some sites use <script
src='fineName.js?ver=XXX'></script(even google)
Someone told me that it's for script changes, means - if the file
in server has been changed than the new XXX will demand to load the
new file.
I find it hard to believe that it's true.
Any suggestions ?

The client cannot "know" the server has a changed file on its HD
without receiving info or the actual file from the server.

However the client [read: browser] sees different querystrings as
diffeent files, and will not take a different file from it's cache,
but will sent out for that new file.
[..]

[Please do not toppost on usenet, and do not quote signatures]
Thanks for your reply,

I made some tests for IE && FF (using http debuggers) and found that
the if script file has been changed then the browser will load the new
script. probably due to it's last modified time stamp.
So if the file has not changed, the browser, having fetched the header
and knowing the lastmodified, will not fetch the rest of the file and
replace the new file?

How did and can you test a unchanged js file is not replaced?
So again, for that reason - there is no need to add ?ver=XXX.
That depends on:
1 if you are right in your testing, I doubt that.
2 if the vers=... was not used to act serverside for other purposes.
So why using it ?
I was not using it, but it seems a good way to force reloading.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 27 '06 #6

P: n/a
Thanks again for your reply,

That exactly my Q, why force reloading if reloading is done any case?

Now about my test, quite simple:
1. Use http debugger like fiddler for ie
2. put script file in your server and reference it from a page.
3. Go to that page address and watch the http header. you'll noticed
that the script file content has been passed to the browser by
'content-length 0'.
4. Refresh the page and you'll see that content-length = 0 for the same
script file.
5. Now go to the server and change the file.
6. Refresh the page in your browser.
7. Watch the debugger note that script file content-length 0.
Done.

Evertjan. wrote:
wrote on 27 aug 2006 in comp.lang.javascript:
Evertjan. wrote:
wrote on 26 aug 2006 in comp.lang.javascript:

I noticed that some sites use <script
src='fineName.js?ver=XXX'></script(even google)
Someone told me that it's for script changes, means - if the file
in server has been changed than the new XXX will demand to load the
new file.
I find it hard to believe that it's true.
Any suggestions ?

The client cannot "know" the server has a changed file on its HD
without receiving info or the actual file from the server.

However the client [read: browser] sees different querystrings as
diffeent files, and will not take a different file from it's cache,
but will sent out for that new file.
[..]

[Please do not toppost on usenet, and do not quote signatures]
Thanks for your reply,

I made some tests for IE && FF (using http debuggers) and found that
the if script file has been changed then the browser will load the new
script. probably due to it's last modified time stamp.

So if the file has not changed, the browser, having fetched the header
and knowing the lastmodified, will not fetch the rest of the file and
replace the new file?

How did and can you test a unchanged js file is not replaced?
So again, for that reason - there is no need to add ?ver=XXX.

That depends on:
1 if you are right in your testing, I doubt that.
2 if the vers=... was not used to act serverside for other purposes.
So why using it ?

I was not using it, but it seems a good way to force reloading.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 27 '06 #7

P: n/a
wrote on 27 aug 2006 in comp.lang.javascript:
That exactly my Q, why force reloading if reloading is done any case?
Sorry, I will not answer anymore,
as you persist in ignoring my request not to toppost.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 27 '06 #8

P: n/a
<ro***********@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Thanks again for your reply,

That exactly my Q, why force reloading if reloading is done any case?
Cache updating based on last-modified date cannot be relied on in all
circumstances.
Users may change their cache settings to never check (or at least not to
check on every request for the same resource).
Or the user is behind a proxy which implements its own caching rules.

Tim
Aug 27 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.