Reputation: 435
When looking at various web pages, I sometimes see statements like the following in the source. These examples are taken from a few different sites.
<script type="text/javascript" src="js/jquery.min.js?v=1.5.1"></script>
<script type="text/javascript" src="js/jquery-ui.custom.min.js?v=1.8.13"></script>
<script type="text/javascript" src="/js/skin/core.js?ver=5212"></script>
<script type="text/javascript" src="/js/skin/plugins.js?ver=5212"></script>
<script type="text/javascript" src="/js/skin/mainpage.js?ver=5212"></script>
<link rel="stylesheet" href="/css/site.css?ver=5212" media="screen" />
<link rel="stylesheet" href="/css/global.css?v=04.23.2012.01" type="text/css" />
<script type="text/javascript" src="/stuff/lib/site.js?v=04.20.2012.00"></script>
<link rel="stylesheet" type="text/css" href="http://css.nyt.com/css/0.1/screen/build/homepage/styles.css?v=20120119">
Can someone explain what these are for and what script is being used for it? Is this so different versions of CSS/JS can be kept and sent based on the version number?
Upvotes: 0
Views: 73
Reputation: 219804
It's there so browsers that have cached a previous version of those files will request a new copy. By adding the version numbers or dates they are essentially creating a new name for the file thus bypassing caching.
Upvotes: 1
Reputation: 36592
This is for cache-busting; changing the parameter ?whatever
forces the browser to download the file again instead of fetching it from the cache.
Upvotes: 5