You are here

function _drupal_flush_css_js in Drupal 6

Same name and namespace in other branches
  1. 8 core/includes/common.inc \_drupal_flush_css_js()
  2. 7 includes/common.inc \_drupal_flush_css_js()
  3. 9 core/includes/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 includes/common.inc
Flush all cached data on the site.
install_tasks in ./install.php
Tasks performed after the database is initialized.
update_info_page in ./update.php

File

includes/common.inc, line 3873
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));
}