Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS parameters?

Tags:

html

css

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?

like image 743
Uffo Avatar asked Jul 02 '26 06:07

Uffo


2 Answers

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.

like image 184
Brandon Avatar answered Jul 05 '26 17:07

Brandon


?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.

like image 41
Moses Avatar answered Jul 05 '26 16:07

Moses