9

I want to set a favicon to be requested from a static file server instead of the main web server for performance optimization.

If I specify a <link rel="shortcut icon" href="http://cdn.site.com/favicon.ico"> but also have a /favicon.ico in my site root as a fallback, which will browsers prefer? Will browsers (and which?) still look for /favicon.ico, making the move to a static file server useless?

Jacob Rask
  • 22,804
  • 8
  • 38
  • 36

3 Answers3

31

I did the test suggested above. I placed a /favicon.ico in the root of a domain, and a link, and fired up the page in:

  1. Opera 10
  2. Opera 9.64
  3. Firefox 3.5
  4. IE 6
  5. IE 7
  6. IE 8
  7. Safari 4

They all showed the icon loaded with <link rel="shortcut icon" href="http://cdn.site.com/favicon.ico"> (located on an external server). I checked access.log, and there were no requests to /favicon.ico!

I then commented out the <link>, checked again in all browsers, and they showed the /favicon.ico icon and corresponding entries in access.log.

Jacob Rask
  • 22,804
  • 8
  • 38
  • 36
7

The answer is: the link should trump the local file on most modern browsers, but it really depends on the implementation with non-mainstream browsers (although you probably don't really care about other browsers than IE, Firefox, Safari and Chrome)

It should also be pretty simple to test this yourself. Just put the favicon.ico file in the site folder and also add a link to a different-looking icon file on the static server and then see which one is loaded in different browsers.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Mike Dinescu
  • 54,171
  • 16
  • 118
  • 151
  • 1
    Thanks, I could do that test, but.. it would also include checking access logs to see if the browser maybe first made a request to favicon.ico but then decided to go with the linked version instead. Sounds unreasonable, but that only makes it more likely IE would do it. – Jacob Rask Oct 12 '09 at 13:53
3

Don't forget that browsers aren't the only thing that will request favicon's - many crawlers and other applications do too.

Andy Davies
  • 5,794
  • 2
  • 26
  • 21