Hey Guys,

I recently started working on a theme for drupal6. The theme seems to be working correctly, styles are being applied, template files seem ok (nott too sure about theme_name.info file), but I keep getting this weird thing at the ending to all css files.

I keep seeing this
R?
at the end of my file path on all css files.
The theme still works, and styles are being applied.

On my server all the files are just names style_name.css but when I look at the source code in firebug, or view the source on any browser I see the files as being:

 <link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?R" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?R" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?R" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?R" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/user/user.css?R" />
<link type="text/css" rel="stylesheet" media="all" href="/themes/ctrlphone/style.css?R" />

M page.tpl.php file looks normal

  <?php print $head; ?>
  <?php print $styles; ?>
  <?php print $scripts; ?>

Any ideas?

Comments

avpaderno’s picture

The letter after the ? (and the ? itself) is added by Drupal to avoid the CSS files get cached by the web browser.
The letter added changes from time in time, and the browser will think that the referred file is different from the one it already has.

-- Kiam@AVPnet

avpaderno’s picture

The function that implements such functionality is _drupal_flush_css_js() that contains the following code:

function _drupal_flush_css_js() {
  $string_history = variable_get('css_js_query_string', '00000000000000000000');
  $new_character = $string_history[0];
  $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  while (strpos($string_history, $new_character) !== FALSE) {
    $new_character = $characters[mt_rand(0, strlen($characters) - 1)];
  }
  variable_set('css_js_query_string', $new_character . substr($string_history, 0, 19));
}

The function is called by drupal_flush_all_caches(), which in turn is called by system_clear_cache_submit().
-- Kiam@AVPnet

yelvington’s picture

If you pay a little closer attention you'll see that the filenames end in ?R, not R? ... the significance is that ? indicates that the characters following are to be parsed for arguments. By rotating through the alphanumeric characters, Drupal ensures that your browser is working with a current version of a (possibly altered) CSS file. This avoids maddening "why is my site not changing when I edit files" experiences.