function _drupal_flush_css_js

7.x common.inc _drupal_flush_css_js()
6.x common.inc _drupal_flush_css_js()

Helper function to change query-strings on css/js files.

Changes the character added to all css/js files as dummy query-string, so that all browsers are forced to reload fresh files. We keep 20 characters history (FIFO) to avoid repeats, but only the first (newest) character is actually used on URLs, to keep them short. This is also called from update.php.

3 calls to _drupal_flush_css_js()
drupal_flush_all_caches in drupal-6.x/includes/common.inc
Flush all cached data on the site.
install_tasks in drupal-6.x/install.php
Tasks performed after the database is initialized.
update_info_page in drupal-6.x/update.php

File

drupal-6.x/includes/common.inc, line 3847
Common functions that many Drupal modules will need to reference.

Code

function _drupal_flush_css_js() {
  $string_history = variable_get('css_js_query_string', '00000000000000000000');
  $new_character = $string_history[0];
  // Not including 'q' to allow certain JavaScripts to re-use query string.
  $characters = 'abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  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));
}