SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member isdixit's Avatar
    Join Date
    Nov 2012
    Location
    Bhopal, IN
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    Code:

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

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,226
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    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.

  3. #3
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,615
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    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.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  4. #4
    SitePoint Member isdixit's Avatar
    Join Date
    Nov 2012
    Location
    Bhopal, IN
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @
    Quote Originally Posted by Force Flow View Post
    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 ?

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,294
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by iSaurabhDixit View Post
    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.

  6. #6
    SitePoint Member isdixit's Avatar
    Join Date
    Nov 2012
    Location
    Bhopal, IN
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks all !

  7. #7
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,615
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by iSaurabhDixit View Post
    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 ?
    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.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  8. #8
    SitePoint Member isdixit's Avatar
    Join Date
    Nov 2012
    Location
    Bhopal, IN
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Force Flow View Post
    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 ?

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,294
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by iSaurabhDixit View Post
    how to use a 'timestamp' instead ?
    The red bit below is the timestamp:

    Code:
    style.css?201312150424
    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.

  10. #10
    SitePoint Member isdixit's Avatar
    Join Date
    Nov 2012
    Location
    Bhopal, IN
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    The red bit below is the timestamp:

    Code:
    style.css?201312150424
    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.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •