ChatGPT解决这个技术问题 Extra ChatGPT

favicon not displayed by Firefox

Locked. There are disputes about this question’s content being resolved at this time. It is not currently accepting new answers or interactions.

I DO know this question has been asked at least a thousand times in this website alone, but I HAVE read many of those threads, I DO consider myself very knowledgeable and rarely ever ask anything, instead prefer to do my own research.

However, THIS issue is so strange, without hope for real enlightenment (since this question HAS been discussed so often and still I could not benefit from reading there), here is my issue:

favicon.ico exists, and (locally hosted development website) http://website/favicon.ico displays the correct icon. Its size is a mere 198 Bytes, so the size limit I found in Firefox's about:config of 1024 Bytes is adhered to. According to the wisdom on favicons on the web the browser should ask for favicons on its own when there is nothing in the of the page. However, my apache log clearly shows Firefox (9.01) never even asks for it.

Next: when I add

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

I still don't get a favicon.

Next: when I instead use

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

(note the trailing "?") I suddenly DO get a favicon. BUt it cannot be a cache issue! First, I have cleared the cache, second, as I mentioned above, I already successfully loaded the icon file into Firefox through its URL http://website/favicon.ico

I am unable to explain this behavior of Firefox. Chrome shows the correct favicon, by the way.

This is my page head:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="shortcut icon" href="/favicon.ico?" />
</head>
...

As soon as I append at least the "?" after "ico" it works.

Here is what the server sends when the icon is requested, since some have asked for this. I have no idea why this would be useful, since a) I said my cache was empty for each test (checked with about:cache too), and b) I said the server is never even asked for the file when it does not show up. Firefox just does not ask without the "?" - with cache empty! The request shows up in the apache log ONLY when I use the appended "?".

Date    Fri, 23 Dec 2011 12:53:22 GMT
Server  Apache/2.2.20 (Ubuntu)
Last-Modified   Fri, 23 Dec 2011 12:02:49 GMT
Etag    "12c07fe-c6-4b4c132190e30"
Accept-Ranges   bytes
Content-Length  198
Content-Type    image/x-icon
Comments are not for extended discussion; this conversation has been moved to chat.
This is the fifth time a moderator has to roll back the post to remove the same rant you've repeatedly told not to put back in. I've now locked it from all edits.

M
Mörre

First, make sure you don't have a "normal" cache problem by loading the favicon URL directly (put it into the browser's URL bar) and force-refreshing it. If that does the job, no need for the complicated solution below.

IMPORTANT:

My original problem cannot have been a cache issue: First, I did clear the cache, second, as I mentioned above, I already successfully loaded the icon file into Firefox through its URL http://website/favicon.ico

So I do (did) get the right icon in the browser when loaded directly! But I still have (had) the wrong icon displayed as "favicon". Loading the icon file directly is (or was) independent of the display in the actual favicon location (except for when it is loaded for the very first time of course).

However, if you only have a cache issue and force-refresh works for your than this question/issue is NOT yours! And your answer isn't an answer for this issue.

People should not ignore facts. When you are bombarded with lots of already answered and/or useless questions the quality of the question suffers for the moment and for the archive too. It is amazing how I have to fight with people who still insist that a force-refresh is the answer!

Note: You can avoid this issue entirely by using a cache-buster URL just like StackOverflow does, their favicon URL ends in .../img/favicon.ico?v=4f32ecc8f43d.

If normal cache clearing measures fail (just like they did for me) an answer is given here: "Clearing All Favicons From Firefox 3 Cache [How-To]" -- and here is an archive.org version of the link (probably slower, but it won't go away).

The steps from that page reproduced here:

Install the Firefox add-on SQLite Manager Launch it from Tools -> SQLite Manager Click the "Database" menu item (top left) and select "Connect Database", enter %APPDATA%\Mozilla\Firefox Open the Profiles folder and go to the profile you use Select places.sqlite as the database file to edit (Firefox 61 and later: favicons.sqlite) Either choose the moz_favicons table. From the right-click context menu use "Empty table", do not use "Drop table" (the table must be there) or use the right-click context menu over the data and select "Delete" over only the one entry that you want to remove (see screenshot below)

https://i.stack.imgur.com/0mF6n.png

I started suspecting that Firefox caches favicons separate from everything else - it was the only explanation matching the observed behavior. So I googled for confirmation and found the above URL. Next I'll try clearing that particular extra cache and see what happens.

UPDATE - SOLVED: After deleting the favicon cache using the "SQLite Manager" Firefox add-on all works as it should.

So the secret was the EXTRA (sqlite) CACHE FOR FAVICONS in Firefox, WHICH IS NOT CLEARED BY THE REGULAR "Clear Cache" command.

Update March 2017: I checked this Firefox add-on and also the standalone app suggested in this answer below and both do the job. The SQLite Manager add-on was last updated ~2 years ago according to its Github project page, but it still does what it's needed for in this context. There are updates available from people who have forked the project, but that is just an aside.


That tool does not do more than what's already built into Firefox: "Temporary files, history, cookies, download history, form history".
I know it's a bit old, but I have found that in Chrome, you can simply point the browser to the favicon itself, so you go to http://www.yourwebsite.com/favicon.ico and afterward your favicon cache should have refreshed
@PhilippeGilbert while that might work in Chrome, it does not in Firefox.
Thank you for this answer, I thought I was going insane! I had no idea that firefox handled favicon cache differently than everything else.
With Firefox 61 you need to open and edit the "favicons.sqlite" database file (instead of the "places.sqlite" db file).
E
EML

Long time ago, I know, but the cache clear procedure on FF 31.0/Windows works for me - maybe it's new. Options -> network -> cached web content -> clear now. Shut down FF, restart. No messing about with SqLite, new favicon loads.

However, there is another potential problem. The server for the site which I was trying to refresh the icon for had a DocumentRoot of /var/www. This site was at foo.com/fubar, where var/www/fubar symlinked to somewhere else. In other words, the site is one level down from DocumentRoot. This works for Chrome, Opera, and IE, but not Safari or FF:

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

FF looks for the favicon in /var/www, instead of /var/www/fubar. This works for all 5 browsers:

<link rel="shortcut icon" href="favicon.ico" >

I just tried with FF 52 and clearing the cache from the network settings page as well as using "clear recent browsing history" from the privacy options did not touch the SQLite database, it was still there unchanged. Your 2nd comment "FF looks for the favicon in /var/www" has nothing to do with the subject here, that is just very simple and basic "URL science" and is a question of your individual webserver setup.
g
gokul

was facing similar issue. Just break the cache of image. I am using MVC Razor View.

    var link = document.createElement('link');
    link.type = 'image/x-icon';
    link.rel = 'shortcut icon';
    link.href = "/images/favicon.ico?t=@DateTime.Now.Ticks";
    var head = document.head || document.getElementsByTagName('head')[0];
    head.appendChild(link);

S
Suraj

Here is how to do it without losing all the favicons

Get an tool that can open SQLite file, i am using DB browser for SQLite go to about:profiles in your browser. open the root folder of default profile. (see attached image for hints) open places.sqlite (favicons.sqlite on Firefox 61+) file. go to moz_favicons table filter and delete the entry for your hostname(see attached image for hints) save file (see image) visit your website it will show new favicon


Yes that works just as well. I just tried both the tool I originally proposed and yours and the handling is pretty similar, although subjectively at least when I just tried, briefly, I liked the Firefox add-on a bit more, but there is not much of a clear difference.
By the way, FYI: I took the liberty of removing the archive.org link to the URL I posted in my answer from the top of your answer since I included it into my answer myself now, thanks for the hint! I thought that this is okay since you explicitly stated that it was for the link in the "accepted answer", otherwise I would not dream of meddling with other people's texts in that way.
Is this answer still valid after Firefox removed the interface of the SQLite engine? how to install sqlite manager addon in firefox quantum (browser version 57)
@AhmedMostafaAbdel-Baky here you are directly editing SQLite files so I believe it should work
This solution worked for me with Firefox 61 except that I had to open and edit the "favicons.sqlite" database file (instead of the "places.sqlite" db file).
u
user3542609

I had this problem just now it seems the cache, cookies, and history have no effect but i did this which fixed it.

1 - Right click on the bookmark (mine is in the toolbar menu) 2 - Click on properties 3 - Then click on cancel (seems to refresh some hidden cache)

im sure clicking ok / save will have the same effect.


Weirdly enough, the icon is shown in the bookmark menu. Just not on the tab.