This is because it might be one of:
- /favicon.ico
- the first successful /link[rel=icon].href
But what if favicon.ico serves with 200 but is an invalid image? Same goes for the icon link elements. Including that sometimes, you can't just pull the data from within the page's JS context using fetch/xhr due to CORS.
So, you need to send the favicon url to the server for fetching, but ensure you have the right browser headers and in some cases cookies etc! Hahah :)
So, serving up the expected favicon is not always trivial. Hahaha! :) Having a canonical url that the browser thinks is right will save a lot of hassle.
Of course, caveats around the response validity are still true, but it's good news or seems so.
Now to obtain this, run Chrome with a remote debugging port and point it at that some URL. Then just curl /json/version on the protocol backend, like so:
google-chrome-stable --remote-debugging-port=9993
curl http://localhost:9992/json
You should see (in latest) a `faviconUrl` field for any page targets returned! :)
0 comments