Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding favicon through a http header

Let's assume that I want to add a favicon on a dynamically generated page (specifically an ADF Faces page, but this is irrelevant). I can't modify a tag of my resulted html. So I try to add a http-header in servlet header. I want my header to be identical to html head element:

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

I'm adding it this way:

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 does not have any effect in IE or Chrome. Anyone tried to achieve the same thing? Am I doing something wrong? Is that should work at all?

like image 464
dragn Avatar asked Jun 27 '12 13:06

dragn


2 Answers

And the answer is: this method relies on proposed standard (a draft) that is not implemented yet (thanks to Salman A for pointing this out). Though it would be great if it worked.

like image 60
dragn Avatar answered Sep 24 '22 22:09

dragn


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

Also see: HTTP Header Stylesheets

What @dragn is suggesting is perfectly viable, and in spec why the browsers aren't adopting is beyond me. There are some other useful relations like prefetch, bookmark and glossary to name a few. The least they could do is notify the user that links exist and provide it as a drop down or menu. Maybe a plugin is what is called for to show the browser vendors what we want it to do as it seems they are all confused. Any suggestions?

For now I guess we have to wait till 2020 for this feature to become available which seems to be the trent.

like image 35
nickl- Avatar answered Sep 26 '22 22:09

nickl-