How to prevent favicon.ico requests?

2018-12-31 19:35发布

I don't have a favicon.ico, but IE always makes a request for it.

Is it possible to prevent the browser to make a request for the favicon of my site? Maybe some META-TAG in the HTML header?

标签: favicon
10条回答
梦该遗忘
2楼-- · 2018-12-31 20:12

You can't. All you can do is to make that image as small as possible and set some cache invalidation headers (Expires, Cache-Control) far in the future. Here's what Yahoo! has to say about favicon.ico requests.

查看更多
十年一品温如言
3楼-- · 2018-12-31 20:14

I suggest putting the website into a .zip/compressed folder. This is what an example webpage looked like in a .zip/compressed folder: WEBSITE IN .ZIP/COMPRESSED FOLDER

This is what it would look like in a normal folder: WEBSITE IN NORMAL FOLDER

查看更多
孤独寂梦人
4楼-- · 2018-12-31 20:16

In our experience, with Apache falling over on request of favicon.ico, we commented out extra headers in the .htaccess file.

For example we had Header set X-XSS-Protection "1; mode=block"

... but we had forgotten to sudo a2enmod headers beforehand. Commenting out extra headers being sent resolved our favicon.ico issue.

We also had several virtual hosts set up for development, and only failed out with 500 Internal Server Error when using http://localhost and fetching /favicon.ico. If you run "curl -v http://localhost/favicon.ico" and get a warning about the host name not being in the resolver cache or something to that effect, you might experience problems.

It could be as simple as not fetching (we tried that and it didn't work, because our root cause was different) or look around for directives in apache2.conf or .htaccess which might be causing strange 500 Internal Server Error messages.

We found it failed so quickly there was nothing useful in Apache's error logs whatsoever and spent an entire morning changing small things here and there until we resolved the problem of setting extra headers when we had forgotten to have mod_headers loaded!

查看更多
人间绝色
5楼-- · 2018-12-31 20:17

I believe I've seen this (I haven't tested it or used it personally though):

<link rel="shortcut icon" href="#" />

Anyone had similar experience?

EDIT:

I just tested the above snippet and on a forced full refresh, no favicon requests were seen in Fiddler. I tested against IE8 (Compat mode as IE7 standards) and FF 3.6.

查看更多
登录 后发表回答