Uffo
Uffo

Reputation: 10046

CSS parameters?

I always see this: <link ... href="style.css?v=1"

What is that ?v=1? How does this work? Can someone explain what this does and why I should it?

Upvotes: 2

Views: 854

Answers (3)

Bouke
Bouke

Reputation: 12138

Another solution (althoud less likely the other two replies) could be that some server-side script is serving the CSS file. The query string would then be used to identify which file to serve.

Upvotes: 1

Moses
Moses

Reputation: 9173

?v=1 is a way you can change the path to your stylesheet without changing the name of the stylesheet. V=1 indicates the version number of the stylesheet.

Whenever you change your CSS stylesheet, because of browser caching it is likely that your users will still be viewing your website with their cached (old) stylesheet. However, including ?v=1 (or whatever vers. you're on) changes the path and thus forces the browser to download the newer version of the stylesheet.

Upvotes: 1

Brandon
Brandon

Reputation: 69993

CSS doesn't accept query string parameters. The v=1 usually indicates the version number of the CSS file, that way it will force the browser to pull the updated file rather than using one in the cache.

The browser will get a new copy whenever it sees that the href attribute has changed. If it stays at v=1 then it won't get a new copy. You should consider doing it this way if your CSS changes regularly.

Upvotes: 11

Related Questions