Adding favicon via HTTP header

Suppose I want to add favicon to a dynamically generated page (specifically an ADF Faces page, but that doesn't matter). I cannot change the tag of my provided html. So I am trying to add the http header in the servlet header. I want my title to be identical to the headt HTML element:

<link rel="shortcut icon" href="http://foo.com/favicon.ico"> 

I add it like this:

 httpResponse.addHeader("Link", "<http://foo.com/favicon.ico>; rel=\"shortcut icon\""); 

And in my browser, I see this header in response:

 Link: <http://foo.com/favicon.ico>; rel="shortcut icon" 

But unfortunately, this has no effect in IE or Chrome. Has anyone tried to achieve the same? Am I doing something wrong? Should this work at all?

+8
html favicon
source share
3 answers

And the answer is this: this method is based on the proposed standard (draft), which has not yet been implemented (thanks to Salman A for pointing this out). Although it would be great if it worked.

+4
source

Yes. Link headers have been a defined standard in RFC 5988 since October 2010, but only the link ratio I've seen that works for a stylesheet and only in some browsers.

See also: HTTP Header Tables

What @dragn offers is completely viable, and in the specification why browsers don't accept is beyond me. There are several other useful relationships, such as prefetching, bookmarking, and a glossary to name a few. Least of all they can do this to notify the user of the existence of links and provide it as a drop-down menu or menu. Perhaps the plugin is what it takes to show the browser vendors what we want them to do, because it seems like they are all confused. Any suggestions?

At the moment, I think we need to wait until 2020 for this feature to become available, which seems to be trent.

+3
source

Yes, yes, " draft " ..

does not matter..

If you want to see how you can use it in Practice, here is an example (taken from icompile.eladkarako.com ) sub>

 <ifModule mod_headers.c> Header set Link <http://icompile.eladkarako.com/favicon.ico>; REL="shortcut icon"; TYPE="image/x-icon" Header set Link <http://icompile.eladkarako.com/favicon.ico>; REL="icon"; TYPE="image/x-icon" Header set Link <http://icompile.eladkarako.com/img/apple-touch-icon.png>; REL="apple-touch-icon"; TYPE="image/png"; sizes="316x316" </ifModule> 

It will work in the current Chromium / Google Chrome / Google Canary,

(and, of course, if you set the switch for advance web-features to chrome://flags )
0
source

All Articles