I don't have a favicon.ico, but IE always makes a request for it.
Is it possible to prevent the browser to make a request for the favicon of my site? Maybe some META-TAG in the HTML header?
I don't have a favicon.ico, but IE always makes a request for it.
Is it possible to prevent the browser to make a request for the favicon of my site? Maybe some META-TAG in the HTML header?
A very simple solution is put the below code in your
.htaccess
. I had the same issue and it solve my problem.Reference: http://perishablepress.com/block-favicon-url-404-requests/
You can use .htaccess or server directives to deny access to favicon.ico, but the server will send an access denied reply to the browser and this still slows page access.
You can stop the browser requesting favicon.ico when a user returns to your site, by getting it to stay in the browser cache.
First, provide a small favicon.ico image, could be blank, but as small as possible. I made a black and white one under 200 bytes. Then, using .htaccess or server directives, set the file Expires header a month or two in the future. When the same user comes back to your site it will be loaded from the browser cache and no request will go to your site. No more 404's in the server logs too.
If you have control over a complete Apache server or maybe a virtual server you can do this:-
If the server document root is say /var/www/html then add this to /etc/httpd/conf/httpd.conf:-
Then a single favicon.ico will work for all the virtual hosted sites since you are aliasing it. It will be drawn from the browser cache for a month after the users visit.
For .htaccess this is reported to work (not checked by me):-
I will first say that having a favicon in a Web page is a good thing (normally).
However it is not always desired and sometime developers need a way to avoid the extra payload. For example an IFRAME would request a favicon without showing it. Worst yet, in Chrome and Android an IFRAME will generate 3 requests for favicons:
The following uses data URI and can be used to avoid fake favicon requests:
For references see here:
The Chrome bug/behavior will probably be fixed in upcoming versions.
Here is the bug submission for you to vote:
UPDATE 1:
From the comments (jpic) it looks like Firefox >= 25 doesn't like the above syntax anymore. I tested on Firefox 27 and it doesn't work while it still work on Webkit/Chrome.
So here is the new one that should cover all recent browsers. I tested Safari, Chrome and Firefox:
I left out the "shortcut" name from the "rel" attribute value since that's only for older IE and versions of IE < 8 doesn't like dataURIs either. Not tested on IE8.
UPDATE 2:
If you need your document to validate against HTML5 use this instead:
You could use
That way it won't actually be requested from the server.
if you use nginx
Just add the following line to the
<head>
section of your HTML file:Features of this solution:
href="#"
)