What does part '?v=1.0' indicates in this code?


<link rel=“stylesheet” href=“css/styles.css?v=1.0”>

My guess is the GET variable signifies version 1.0
Used so that when/if the file is updated the browser won’t use an older cached version.

The query variable is intended to force the browser to download the CSS file if it changes and bypass any caching settings either on the server or in the browser.

So, for example, if your site already has style.css?v=1.0, if you make some changes and change it to style.css?v=1.1, this will force the browser to re-download the file and overwrite the old one in the browser’s cache. The query variable essentially makes the whole URL to the file unique.

Note, that the current practice for this is now to use something like this: styles.css?201312150424. This is because the query variable can fail to work as intended under certain conditions–typically with proxies or certain content filters on a user’s network.


Thanks !
In the code mentioned as: style.css?201312150424
does that number changes/or have to be changed to something else when we intend to make any change in the style.css file itself ?

It doesn’t have to be changed, but the whole point of having it there is to change it each time you update the file.

If people visit your site regularly and you make a CSS change, it’s possible the site will look broken to them next time they visit is their browser just uses the old version of the CSS file cached in their browser—unless you are appending a different timestamp each time.

Thanks all !

I change the number that follows the file every time I update the file.

I’ve been tending to use a timestamp rather than a version number since you can’t really include symbols (periods/dashes), so it’s hard to tell version numbers from each other (like 1.1.0 from 11.0). Plus, with websites that are undergoing perpetual updates, version numbers on every single supporting file aren’t always all that helpful. But–this all depends upon your particular workflow.

how to use a ‘timestamp’ instead ?

The red bit below is the timestamp:


It’s just the year, day, month, hour and minute (2013-12-15-04-24). You can either type it manually or just get a language like PHP to add it automatically.

Thanks, for this !
I finally got its touch.