You are here:Home»KB»Media»Windows, Firefox, Favicon, Internet Shortcuts and Caching
Saturday, 27 January 2018 09:47

Windows, Firefox, Favicon, Internet Shortcuts and Caching

Written by

This article will cover some of the favicon cache issues you get when working with Windows 10 and Firefox 56.0.2 (64-bit), but the information will probably apply to other setups.

If your Favicon is cached and you cannot unchache the icon then this article will guide you through the process of fixing that and why.

Where does an Internet Shortcut icon come from?

Internet Shorcuts are handled by your default browser. There are 2 ways to create an Internet Shortcut.

The following article goes into some depths about this. How do I set a custom icon for a desktop URL shortcut? - Ask Leo!

  • Most of the Windows system icons are stored in C:\Windows\System32\shell32.dll
  • The World icon is stored in C:\Windows\System32\url.dll

Right Click

On the Windows desktop, right click and create a new shortcut but using a URL as the location. This will create a shorcut that uses the Firefox default icon but I have seen it use the favicon before now.

The icon created typically looks like:

Right Click Icon

With the code inside the shortcut:

[{000214B0-0000-0000-C000-000000000048}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://quantumwarp.com/

Drag and Drop

In Firefox highlight the URL in the address bar and drag it to the Windows desktop.

This method always creates a shortcut using an icon created by using the Favicon (48px or highest quality layer in the icon) stored in Firefox and then super imposes this on a white background. This leads to a very small icon in the middle of a white square. a lot of people complained about this so it is possible to change this behavious to use the normal Firefox icon. If the icon does not exist in Firefox then the icon will be grabbed from the website via Firefox internally and the same process will occur. If no Favicon exists then you might see a World icon.

Some other browsers might support this feature but I have not tested them.

The icon created could looks like one of these:

Drag and Drop Icons

As you can see it has used the URL title for the description, this can be changed by renaming the shortcut.

With the code inside the shortcut:

[InternetShortcut]
URL=https://quantumwarp.com/
IDList=
HotKey=0
IconFile=C:\Users\testuser\AppData\Local\Mozilla\Firefox\Profiles\727ui0od.default-1577462149946\shortcutCache\TiE1mKLHrw+Is5_yDymu0w==.ico
IconIndex=0

Favicons not showing correctly in File Explorer but do show correctly in Firefox

This is an easy one to explain (after a lot of research) but first you need to know the process Windows goes through to create the shortcut.

The Process

When creating an internet shortcut via drag and drop the following occurs:

  1. User drags the URL from Firefox
  2. Firefox checks to see if it has a Favicon is in its Favicon cache (favicons.sqlite) for the given URL:
    • Icon present in cache - If there is a Favicon in the cache Firefox uses it.
    • No icon in cache - Firefox will attempt to download the favicon.ico from the URL, if success it will add the favicon.ico to the cache and use this icon. If there is no favicon.ico found then Firefox will use one of the following icons default Firefox icon, the World icon or White Paper icon instead. Firefox now skips to Step 5.
  3. Firefox now check if it has an icon in its shortcutCache:
    • Icon present in cache - Firefox will use this cached icon.
    • No icon in cache - Firefox creates an icon of the URL and adds it to the cache by creating an icon (A white square with the favicon in the middle which looks really small) in the /shortcutCache/ folder. The favicon layer used to create a shortcut icon in QuantumnWarps case is (48x48) but Firefox might use the highest resolution layer available. There seems to be a bug, even if there is no icon in this cache but the icon has previously been cached in the windows IconCache then an icon location is still sent back to Windows.
  4. Firefox now gives Windows the location of the custom icon.
  5. Windows checks its own IconCache for the URL to see if there is already an icon:
    • Icon present in cache - Windows will use this cached icon.
    • No icon in cache -Windows adds the supplied icon to the IconCache, and will use this cached icon.
  6. Windows now builds the shortcut with the supplied icon.

Cause

As you can see there are 3 caches involved, this is where the issue creep in. The favicon might be correct in Firefox but because Windows has its own independent cache the old version can persist within the Windows cache.

Solution

The only way to get a Windows Internet Shorcut Icon to have an upto date icon is to:

  1. Wipe the Firefox Favicons Database
  2. Wipe the Firefox Shortcut Cache
  3. Refresh/Wipe the Windows Icon Cache
  4. and then re-create the icon. (Not always required, but can speed things up)

NB: Firefox Favicons stored in the database expire after 7 days but I do not know if that causes the Internet Shortcuts Icons in the shortcutCache to be automatically updated or if you need to visit the URL in question or they do not get updated at all. Depending on the answer you might only need to wipe/refresh the Windows Icon cache if the favicon that you need to update is older than 7 days. One further thing you could try is to set the expiry data in the Firefox database for all of the required Favicons to 0 or another time in the past.


Firefox Favicon Caching

I have changed my favicon on my site but my Firefox Bookmark icon has not changed. This is because the favicon is cached but not within the normal Firefox file cache.

You can possibly bypass this problem if you use versioning on your favicon by using the following code to declare your favicon.ico changing the variable when you make change.

<link rel="shortcut icon" href="/favicon.ico?v=QWr4XjEpXx">

Disable the use of Favicons for Internet Shortcuts

You can disable the use of Favicons for Internet Shorcuts by modifying some Firefox settings in about:config, this also assumes Firefox is the default browser of Windows.

In about:config set these options to false and restart the browser.

browser.chrome.favicons
browser.chrome.site_icons

The original article from HowToGeek -  Quick Tip: Disable Favicons in Firefox | HowToGeek

Location of Favicon Cache

When you visit a site in Firefox it caches the favicon.ico, favicon-16x16.png, favicon-32x32.png (only 1 of the png is stored, 16x16 if both present).

It caches them in it's own database as BLOBs and the location varies from version to version. It only ever grabs the following layers 16/32/48.

FF <55 - %AppData%\Mozilla\Firefox\Profiles\.default\places.sqlite
FF 55+ - %AppData%\Mozilla\Firefox\Profiles\.default\favicons.sqlite

After research I can confirm the expiry date set on all favicon assets in the database is 7 days. I have not found anywhere that this can be changed. It should also be noted that changing caching options in your .htaccess seems to make no difference.

Firefox 55.0 got a new storage system for Favicon data.

Moved from the places.sqlite file into its own 'favicons.sqlite' file, along with adding two temporary storage files 'favicons.sqlite-wal' and 'favicons.sqlite-shm' which are used while Firefox is running. Then as Firefox is closed the temporary data is written to the main 'favcions.sqlite' file.

The goals for the new storage system include saving the new Favicon with the newly saved bookmark (vs being saved upon the first use of the new bookmark) and the ability for Favicons to be Sync'd (although I'm not sure if the Sync service has been updated just yet).

Favicons Disappear After 55+ Updates | Firefox Support Forum | Mozilla Support

Clear Firefox Favicon Cache

So for those of us who are developing our sites often we need a way to be able to empty the favicon cache. This is not always as easy as it seems so I will outline what works.

Option 1

  • Download and install DB Browser for SQLite. (You could also try the addon SQLite Manager but I have not tried this.)
  • Quit Firefox (close all open Firefox windows).
  • Open the following database with DB Browser. Your profile name might be different, so change as required.
    %AppData%\Mozilla\Firefox\Profiles\.default\favicons.sqlite
  • Click on the 'Browse Data' tab. All you icons will now be listed.
  • Select the favicons you want to delete.
  • Click the 'Delete Record' at the top right.
  • Write the changes.
  • Done, you can now restart Firefox.

Option 2 (not tested)

  • As above but instead of deleting the record you can set the expiry date to 0 (or other past date). the icon in this case will stay until it is refeshed by visiting the website.

Other Options

These are a collection of links with different ways of doing this. I have not test any of them but they are for reference.

Location of the Firefox Internet Shortcut Icons

  • Create a shortcut by the Drag and Drop method
  • Edit the .url/shortcut file by using a text editor such as Notepad++
  • You will see some code similiar to that below
    [InternetShortcut]
    URL=https://quantumwarp.com/
    IDList=
    HotKey=0
    IconFile=C:\Users\testuser\AppData\Local\Mozilla\Firefox\Profiles\727ui0od.default-1577462149946\shortcutCache\TiE1mKLHrw+Is5_yDymu0w==.ico
    IconIndex=0
  • Open that folder named in IconFile and you will see all of the icons used for shortcuts. (Remember that windows has already cached these)

Clear Firefox Internet Shortcut Icon Cache

This is the easiest cache to clean.

  • Delete all of the files in:
    %LocalAppData%\Mozilla\Firefox\Profiles\.default\shortcutCache\

Notes

  • The icons have filenames like TiE1mKLHrw+Is5_yDymu0w==.ico. These are not random. Firefox is aware if an icon has been already created for this domain and will use the same icon location even if you have deleted it or if an icon for that URL exists it will re-use it. This means that Firefox must keep a reference table for URL against icon name or it is some sort of hash. I have looked through the Firefox databases and search the Windows registry but have not found anything. I might of missed it.
  • This random name also seems to be used by the Windows icon cache.

Windows Icon Cache

As of now I do not believe that there is any Windows event that expires the Icon Cache or that they have an expiry date.

How to wipe the Windows Icon Cache

Most of the delete icon cache out there refer to just deleting the IconCache.db and this is ok for Windows 7 but is not correct for windows 10. The file IconCache.db is still present in Windows 10 but is no longer used. The icons are now stored in the following folder within the files all starting with iconcache*.

%LocalAppData%\Microsoft\Windows\Explorer

Option 1 - Refresh the Cache

This is where you can refresh the icons without needing to reboot the PC.

After issuing this command, icons might not refresh but instead change into Blank Paper icons. This is probably because you have emptied the Firefox Internet Shorcut Cache and Windows cannot find the correct icon so it uses the first icon (Blank Paper) in the default icon library (C:\windows\system32\shell32.dll). You can fix this by recreating the shortcut for the URL using the Drag and Drop method, this will cause the favicon to be downloaded again consequently this Internet Shortcut icon will display correctly with the new version of the icon. You also find all other shortcuts that were using the same icon will now also be restored but using the newer icon. You do not need to recreate each one individually, it is only because the icon is missing from the shortcutCache folder that we do this.

Open a command prompt and enter the appropriate command:

For Windows 7 and 8 use

ie4uinit.exe -ClearIconCache

For Windows 10

ie4uinit.exe -show

Notes

Option 2 - Manually Delete Files

  1. Open command console with admin privileges
  2. taskkill /IM explorer.exe /F
  3. cd /d %LocalAppData%
  4. del IconCache.db /a
  5. cd /d %LocalAppData%\Microsoft\Windows\Explorer
  6. del iconcache*
  7. explorer

NB: If some of the iconcache* files do not delete, logout, log back in and repeat the process, this should be enough. Once the icons have refreshed it would not harm to reboot, this is optional.

Notes

Option 3 - Other Apps


Links

Read 5881 times Last modified on Friday, 16 March 2018 17:14