Thursday, May 5, 2011

why does drupal append ?1 to my css file links

My designer noticed that in the source for a drupal site, all the .css files were getting appended a ?1 that he was concerned would break things. Why is it doing this?

<link type="text/css" rel="stylesheet" media="all" href="/modules/modules/node/node.css?l" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/modules/system/defaults.css?l" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/modules/system/system.css?l" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/modules/system/system-menus.css?l" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/modules/user/user.css?l" />
From stackoverflow
  • I poked around in the source code for drupal and found this:

    // A dummy query-string is added to filenames, to gain control over
    // browser-caching. The string changes on every update or full cache
    // flush, forcing browsers to load a new copy of the files, as the
    // URL changed.
    $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
    

    I guess that answers that. I'm going to assume since the drupal guys are doing this that browsers are cool with query strings in css link tags, even though my designer was paranoid over it.

    Hopefully this helps somebody one Google on day =p

    Henrik Opel : @easel: You should mark this as the accepted answer (doesn't matter that it is your own)
    easel : thanks for the hint =p done
  • Following blog post explains this practice too: mod_expires and Cache Killers

    easel : cool, thanks. Some good details there!

0 comments:

Post a Comment