commit 1d90b8be2cfa57ecb81e8d15ae187709858c2bfa Author: James Wilson Date: Tue Mar 5 16:33:35 2013 -0500 Cache-controlled logo and favicon. diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 3051560..c748c5b 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1436,32 +1436,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('core/misc/favicon.ico'); + $favicon_path = file_create_url('core/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; + } } } }