Cache clear doesn't affect logo or favicon

Created on 5 March 2013, about 12 years ago
Updated 5 April 2025, 18 days ago

Recommend commit message:

Issue #1934508 by jwilson3, clemens.tolboom, wesleydv, matglas86, longwave, sidharthap, superspring, MegaChriz: Make cache clear affect logo and favicon.

Problem/Motivation

Drupal has a great piece of functionality for front-end developers to force browsers to reload css and javascript. However, this same courtesy is not extended to the favicon and the logo image.

Developers using a git/svn based deployment process cannot overwrite the logo.png or favicon.ico files in a theme, deploy into a production environment, and expect the site to display the updated files because browsers that have already visited the site will pull these files from their cache.

From a front-end developer perspective, theme_get_setting does not provide any clean method to alter the data in order to add a cache-busting query string from a custom module or theme, thus the only way to ensure all browsers get a new version of these files is to either specify a separate path to a different logo or favicon file or upload a file with a different name. This can be done only via the Appearance page in the Drupal administrative user interface or by writing an update script in a custom module.

Proposed resolution

The proposed solution here appends the standard Drupal browser cache-busting string (css_js_query_string) to the logo and favicon URLs generated in theme_get_setting.

Remaining tasks

None.

User interface changes

No visible changes out of the box. But, because we've added query strings to the logo and to the favicon URLs, a net positive effect on rendering will occur when a site administrator updates the favicon or logo files on the server. A subsequent cache clear will guarantee all visitors will see the new file instead of the old file from cache.

API changes

The Drupal CSS/JS query-string internal variable has been renamed from css_js_query_string to drupal_asset_query_string, and the internal function _drupal_flush_css_js() to _drupal_flush_assets(), because both affect not only CSS and JS anymore.

โœจ Feature request
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Themeย  โ†’

Last updated 5 days ago

Created by

๐Ÿ‡ช๐Ÿ‡จEcuador jwilson3

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States matthand Riverdale Park, Maryland

    I still see this as an issue in Drupal 10. Even clearing the browser cache data doesn't easily solve the problem for the visitor. If a visitor already visited the website previously, the cached version of the logo and favicon is displayed even if there is a newer version of the files. Adding a cache busting query string looks like a good solution to me.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pradhumanjainOSL

    pradhumanjain2311 โ†’ made their first commit to this issueโ€™s fork.

  • Merge request !10502Add query string to logo and favicon โ†’ (Open) created by megachriz
  • Pipeline finished with Failed
    4 months ago
    Total: 132s
    #364266
  • Pipeline finished with Failed
    4 months ago
    Total: 147s
    #364267
  • Pipeline finished with Failed
    19 days ago
    Total: 628s
    #465660
  • Pipeline finished with Failed
    19 days ago
    Total: 554s
    #465687
  • ๐Ÿ‡ช๐Ÿ‡จEcuador jwilson3

    jwilson3 โ†’ changed the visibility of the branch drupal-1934508-1934508-cache-clear-doesnt to hidden.

  • Pipeline finished with Failed
    18 days ago
    Total: 753s
    #466264
Production build 0.71.5 2024