Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a very simple site, with no graphics, and I don't want to spoil it with a huge JavaScript monitoring loop.

I don't have a favicon.ico, and I always see 404 requests from browsers requesting for favicon; can I 307 the favicon location to the //mc.yandex.ru/watch/id URL of the 1×1 gif counter, the one which shows in the img src when you request the Metrica code from Yandex?

    location = /favicon.ico {
            return  307     http://mc.yandex.ru/watch/XXX;
share|improve this question

Certain browsers will always search for a favicon and will carry on doing so until you place the file. There is absolutely no reason why you should need to put a 307 or any other redirect method for that matter simply to get rid of a 404 error.

404's does not imply your site is broken

It's important to note that errors 404 does not indicate that something is broken on the site, if a browser is requesting a file that simply doesn't exist on your server then a 404 response is completely valid.

Redirecting a Favicon 404

Redirecting a favicon with 307 is a bad idea, browsers will still request the file and by adding a 307 you are adding an additional request to your server therefor adding delay unnecessary on the page.


You can design a favicon even though the rest of the site uses no graphics doesn't mean you can't have a favicon. It's actually rather good for tab bars in modern browsers.

Upload a 0 byte favicon.ico to your server, but that means the default browser favicon will not be displayed

Best method - Remove these errors from your logs, you can filter out this information from your logs and that way you never see them... Remember browsers will always request this file and even with redirect it doesn't stop the problem - redirecting is fixing nothing but more of a cosmetic fix for your logs, the correcy way is to filter these errors from your logs.. In Apache you can remove these errors by using:

Redirect 404 /favicon.ico

<Location /favicon.ico>
    ErrorDocument 404 "No favicon

For alternative server platforms you should find many solutions on Stack Overflow and Google.

share|improve this answer

Browsers tend to cache favicons for longer than normal files, so trying to use it as your counter would probably make the counter quite unreliable. Even if it worked this would slow down your page unnecessarily, since you're adding a redirect into the mix.

Just stick with the standard code, and if the favicon errors are a problem use one of the options bybe mentioned. Adding an empty favicon with a long expires header is generally the best solution, since this gets rid of the errors and reduces the volume of requests (for regular visitors).

share|improve this answer
it's not my experience that favicons are cached at all -- I routinely see multiple 404 errors from every visitor, which indicates that favicons generally aren't cached at all (you'd expect they are, but, apparently, they arean't). also, i'm very doubtful that this will make the page load slower -- favicon is not part of page rendering, so, if anything, it'll actually be faster if the counter is in favicon than on the page, because if it were on the page, then it would definitely slow down page rendering – cnst May 7 '13 at 15:33
I wouldn't expect browsers to cache the result of a request that resulted in a 404, but if you've ever tried to change a favicon you'll know that browsers can hang on to the old one for much longer than they would a normal image (regardless of cache headers) so I think they treat them differently. I take your point about page rendering, but if I can pedantically argue semantics, the favicon is part of the 'page load', so adding in a redirect does slow down the page load, even if it may well technically improve the page render time. – Tim Fountain May 7 '13 at 15:56
Just to add that browsers definitely do cache favicons that do exist, this is quite easy to verify: webpagetest.org/result/130507_A7_Q9A (compare favicon request in first view and its absence in the repeat view). – Tim Fountain May 7 '13 at 16:01
up vote 1 down vote accepted
location = /favicon.ico {
        return  307     http://mc.yandex.ru/watch/XXX;

seems to work; however, it would seem like only certain browsers request a favicon.ico by default, so, not all visitors would be counted.

Also, it has a limitation of not letting you know which pages are popular on your site: when a redirect is made, it is likely that the Referer would be the /favicon.ico location, and not the location for which the favicon is allegedly loaded.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.