简体   繁体   中英

What does ver=3.1.2 at the end of ajax.js or filename.js?ver=3.1.2 mean?

I am having some conflicting jquery issues on a website and as I was trying to figure it out, I have noticed the following suffixes in my head files:

ajax.js?ver=3.1.2'></script> 
jquery.prettyPhoto.js?ver=3.1.2'></script> 
jquery.cycle.all.2.72.js?ver=3.1.2'></script> 
jcarousellite_1.0.1.min.js?ver=3.1.2'></script> 
jquery.kwicks-1.5.1.pack.js?ver=3.1.2'></script> 
ddsmoothmenu.js?ver=3.1.2'></script> 
js.js?ver=3.1.2'></script> 

obviously the 3.1.2 is probably some type of "latest update" or something. How does it work? How do you synch theme or balance them out?

Would these other files be failing because of mixed versions? Here the rest of it:

.css?ver=20110325' type='text/css' media='all' /> 
.css?ver=3.1.2' type='text/css' media='all' /> 
l10n.js?ver=20101110'></script> 
jquery.js?ver=1.4.2'></script> 
all.js?ver=3.1.2#xfbml=1'></script> 
comment-reply.js?ver=20090102'></script> 

Not sure if this is the way I should post on Stackoverflow so feel free to edit as it should.

The idea is that the js files are given far future expires headers, so the browser is instructed not to download that file again.

To allow the files to be changed, whilst still having them cached this cache busting query string is often added so that you can change the ver bit and the browser thinks its a new file.

It doesn't actually do anything server side, it's just a neat way to do that.

It's actually a pretty bad way, as some proxy servers don't cache things with query strings, so a better way would be to embed something into the filename, rather than a query string.

3.1.2 seems like the version of the app you're working on, and not that of the js/css libraries themselves. One reason for doing something like this, is that when you update your code, you don't have to worry about the browser using an older cached version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM