commit b79293ff4e09828202edc95c7bea66c3ba1d1911 Author: James Wilson Date: Tue Mar 5 16:48:16 2013 -0500 Cache-controlled Logo and Favicon (http://drupal.org/node/1934508). diff --git a/www/includes/theme.inc b/www/includes/theme.inc index 777922f..b96491b 100644 --- a/www/includes/theme.inc +++ b/www/includes/theme.inc @@ -1445,32 +1445,48 @@ function theme_get_setting($setting_name, $theme = NULL) { } } + // 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 = variable_get('css_js_query_string', '0'); + // Generate the path to the logo image. if ($cache[$theme]['toggle_logo']) { + $logo_path = ''; if ($cache[$theme]['default_logo']) { - $cache[$theme]['logo'] = file_create_url(dirname($theme_object->filename) . '/logo.png'); + $logo_path = file_create_url(dirname($theme_object->filename) . '/logo.png'); } elseif ($cache[$theme]['logo_path']) { - $cache[$theme]['logo'] = file_create_url($cache[$theme]['logo_path']); + $logo_path = file_create_url($cache[$theme]['logo_path']); + } + if (!empty($logo_path)) { + $query_string_separator = (strpos($logo_path, '?') !== FALSE) ? '&' : '?'; + $cache[$theme]['logo'] = $logo_path . $query_string_separator . $query_string; } } // Generate the path to the favicon. if ($cache[$theme]['toggle_favicon']) { + $favicon_path = ''; if ($cache[$theme]['default_favicon']) { if (file_exists($favicon = dirname($theme_object->filename) . '/favicon.ico')) { - $cache[$theme]['favicon'] = file_create_url($favicon); + $favicon_path = file_create_url($favicon); } else { - $cache[$theme]['favicon'] = file_create_url('misc/favicon.ico'); + $favicon_path = file_create_url('misc/favicon.ico'); } } elseif ($cache[$theme]['favicon_path']) { - $cache[$theme]['favicon'] = file_create_url($cache[$theme]['favicon_path']); + $favicon_path = file_create_url($cache[$theme]['favicon_path']); } else { $cache[$theme]['toggle_favicon'] = FALSE; } + if (!empty($favicon_path)) { + $query_string_separator = (strpos($favicon_path, '?') !== FALSE) ? '&' : '?'; + $cache[$theme]['favicon'] = $favicon_path . $query_string_separator . $query_string; + } } } }