1

While looking through the access log of my webserver, I notice a few favicon requests that shows 404 error:

16:17:28 GET /folder/abc.jpg 200 http://example.com/ Mozilla... Firefox/31.0
16:17:28 GET /folder/efg.png 200 http://cdn.example.com/style.css Mozilla... Firefox/31.0
16:17:38 GET /favicon.ico 404   - Mozilla... Firefox/31.0

This comes as a surprise to me because I have the following HTML code to tell browsers where to fetch the favicon on all my web pages.

<link rel='shortcut icon' href='//cdn.example.com/images/favicon.ico'>

Somehow, I still receive requests to http://example.com/favicon.ico occasionally even though Firefox did download the favicon from the alternate location. Is this behaviour peculiar to Firefox browsers or do I have to provide a favicon in the webroot to avoid 404 errors?

Further, if I provide both, which favicon would the browser use?

2

Some bots and older browsers

Some bots and older browsers will ignore custom favicon paths and will attempt to fetch a locally stored favicon from the root /. A simple fix would be to copy the favicon from the CDN and store it locally on the site just to satisfy those bots and browsers, you could also setup a redirect using something like redirect 301 /favicon.ico http://www.example.com/favicon.ico

Potential problem

This may not be revelant as you may have just deleted it when copying it into the question but it seems that your code is invalid (If not let me know so I can delete this).

Invalid Code:

`<link rel='shortcut icon' href='cdn.example.com/images/favicon.ico'>` 

HTTP Valid Code #1:

`<link rel='shortcut icon' href='http://cdn.example.com/images/favicon.ico'>` 

HTTPS & HTTP Valid Code #1:

`<link rel='shortcut icon' href='//cdn.example.com/images/favicon.ico'>` 
| improve this answer | |
  • FireFox 31 is the latest browser. Yes, Google image bot is also ignoring my custom path. I don't think a 301 will change their behaviour. Seems like I would have to add favicon to webroot then. Ah, you spotted my typo mistake, I have corrected that in my question. Thanks. – Question Overflow Aug 6 '14 at 11:05
  • Perhaps serve only your most basic 16x16 ico from the webroot ("bots and older browsers"), and your "retina-ready" ico on your CDN? – MrWhite Aug 6 '14 at 16:23
0

I found that you don't have to specify favicon. just paste it to the root folder and it will sometimes automatically add it. You can specify favicon just in case for new browsers. The root folder is the best place to place favicon's, just a suggestion. Best regards.

| improve this answer | |
  • I think that maybe you've missed the point of the question. The OP is wanting to serve their favicon from an entirely different location... a CDN from which they are probably serving all their static content (a feature that the LINK element provides). – MrWhite Aug 6 '14 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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