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:
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:
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:
- User drags the URL from Firefox
- 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.
- 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.
- Firefox now gives Windows the location of the custom icon.
- 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.
- 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:
- Wipe the Firefox Favicons Database
- Wipe the Firefox Shortcut Cache
- Refresh/Wipe the Windows Icon Cache
- 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.
- Refresh favicon in bookmarks (Firefox) - Stack Overflow - This gives you SQL commands that you can use in DB Browser
- Clearing A favicon.ico From FireFox’s Cache – marcusjenkins.com - older tutorial using a firefox addon called SQLite Manager
- FavIcon Reloader up to FF 48 only – Add-ons for Firefox - An addon dedicated to refreshing your Favicons. Not been updated in a while.
- Booked marked site favicon will not update | Firefox Support Forum | Mozilla Support - This gives you code you can put straight in the Web Developer Toolbar command line.
- Delete browsing, search and download history on Firefox | Firefox Help - this gives you information of what emptying your history does.
- How to Clear Favicon in Firefox's Cache | It Still Works | Giving Old Tech a New Life - This mentions emptying your 'Cached Web Content'
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
- How to Refresh or Clear the Icon Cache Quickly Using IE4UINIT.exe | winhelponline
- Refresh Icon Cache Without Rebooting - Super User
Option 2 - Manually Delete Files
- Open command console with admin privileges
- taskkill /IM explorer.exe /F
- cd /d %LocalAppData%
- del IconCache.db /a
- cd /d %LocalAppData%\Microsoft\Windows\Explorer
- del iconcache*
- 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
- How to Rebuild a Broken Icon Cache in Windows 10 This is an indepth Tutorial on how to wipe the cache for both Windows 7 and Windows 10 (Recommended)
- How to Clear and Rebuild the Icon Cache in Windows | winhelponline - this also has a cleariconcache.vbs to do this automatically. I have not tested the VB Script.
- Icon Cache - Rebuild - Windows 7 Help Forums - although for Windows 7 there is a Rebuild_Icon_Cache.bat that can be easily altered for Windows 10.
- FavIcons not showing correctly in File Explorer but do show correctly - Microsoft Community - Gives the manual instructions on how to wipe the icon cache in Windows 7. This is the first article I found that was useful.
- Refresh Icon Cache Without Rebooting - Super User - Has information on the manual method despite the title.
Option 3 - Other Apps
- Icons Refresh | GitHubIcons Refresh is a program to refresh Desktop, Start Menu and Taskbar icons without restart Explorer. (Not tested)
- Winaero - This uses Winaero to reset the Windows Icon Cache. See also Change a pinned app’s shortcut icon on the taskbar in Windows 10 (Not tested)
Links
- jeffdav on code: why doesn't the favicon for my site appear in IE7? - some sensible questions and answers, although focussed on IE7 some of the answers apply to others browsers and situations.
- favicon-cheat-sheet | GitHub - Obsessive cheat sheet to favicon sizes/types. Please contribute! (Note: this may be in flux as I learn new things about favicon best practices.)
- 1293043 - The icons of the Internet links are too small since the last update - not to see - Technical discussion over at Mozilla about the small cion size in an internet shorcut. It also has a direct link to the appropriate code.
- URL File Extension - What is a .url file and how do I open it?