吻痕怎么快速消除脖子上的吻痕/favicon.ico

How to prevent favicon.ico requests? - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
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?
2,54241928
11.4k2582113
I will first say that having a favicon in a Web page is a good thing (normally).
However it is not always desired and sometime developers need a way to avoid the extra payload. For example an IFRAME would request a favicon without showing it.
Worst yet, in Chrome and Android an IFRAME will generate 3 requests for favicons:
"GET /favicon.ico HTTP/1.1" 404 183
"GET /apple-touch-icon-precomposed.png HTTP/1.1" 404 197
"GET /apple-touch-icon.png HTTP/1.1" 404 189
The following uses data URI and can be used to avoid fake favicon requests:
&link rel="shortcut icon" href="data:image/x-," type="image/x-icon"&
For references see here:
The Chrome bug/behavior will probably be fixed in upcoming versions.
Here is the bug submission for you to vote:
From the comments (jpic) it looks like Firefox >= 25 doesn't like the above syntax anymore. I tested on Firefox 27 and it doesn't work while it still work on Webkit/Chrome.
So here is the new one that should cover all recent browsers. I tested Safari, Chrome and Firefox:
&link rel="icon" href="data:;base64,="&
I left out the "shortcut" name from the "rel" attribute value since that's only for older IE and versions of IE & 8 doesn't like dataURIs either. Not tested on IE8.
If you need your document to validate against HTLM5 use this instead:
&link rel="icon" href="data:;base64,iVBORw0KGgo="&
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
about favicon.ico requests.
87.4k14132162
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?
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.
4,62541947
There's a bunch of good answers, but I think the best answer as well as discussion of alternatives is on this .
The best seemed to be base64 encode the image in js, and feed the favicon link with a hash - the latter suggested above.
A few other variations were proposed as well.
1,02811115
You can use .htaccess or server directives to deny access to favicon.ico, but the server will send an access denied reply to the browser and this still slows page access.
You can stop the browser requesting favicon.ico when a user returns to your site, by getting it to stay in the browser cache.
First, provide a small favicon.ico image, could be blank, but as small as possible. I made a black and white one under 200 bytes. Then, using .htaccess or server directives, set the file Expires header a month or two in the future. When the same user comes back to your site it will be loaded from the browser cache and no request will go to your site. No more 404's in the server logs too.
If you have control over a complete Apache server or maybe a virtual server you can do this:-
If the server document root is say /var/www/html then add this to /etc/httpd/conf/httpd.conf:-
Alias /favicon.ico "/var/www/html/favicon.ico"
&Directory "/var/www/html"&
&Files favicon.ico&
ExpiresActive On
ExpiresDefault "access plus 1 month"
&/Directory&
Then a single favicon.ico will work for all the virtual hosted sites since you are aliasing it. It will be drawn from the browser cache for a month after the users visit.
For .htaccess this is reported to work (not checked by me):-
AddType image/x-icon .ico
ExpiresActive On
ExpiresByType image/x-icon "access plus 1 month"
A very simple solution is put the below code in your .htaccess. I had the same issue and it solve my problem.
&IfModule mod_alias.c&
RedirectMatch 403 favicon.ico
&/IfModule&
Reference:
3,10432940
You could use
&link rel="shortcut icon" href="http://localhost/" /&
That way it won't actually be requested from the server.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled如何更改网站的 ico图标_百度知道
如何更改网站的 ico图标
网站标志是.ico文件。浏览器调用Favicon的原则是首先在网页所在的目录下寻找Favicon.ico文件,如果没有,便到网站的根目录下寻找。因此,在网页中使用Favicon最简单的办法便是将制作好的图标文件命名为Favicon.ico,然后将其上传到网站的根目录即可。如果需要将Favicon.ico放到其他目录下,或者希望让不同的网页显示不同的Favicon,就需要在网页Html文件中做设定了,具体设置也很简单,在Html中的部分加入如下的代码:&link rel=&icon& href=&/dir/favicon.ico& mce_href=&/dir/favicon.ico& type=&image/x-icon&&&link rel=&shortcut icon& href=&/dir/favicon.ico& mce_href=&/dir/favicon.ico& type=&image/x-icon&&Firefox还支持GIF动画格式的Favicon,使用方法如下:首先制作一个16*16的gif动画,然后在html代码&head&&/head&中加入如下代码:&link rel=&shortcut icon& href=&favicon.ico& &&link rel=&icon& href=&animated_favicon.gif& type=&image/gif& &如果网站模板是 XHTML 规格的,就在最后的&前加个/。注:如果想要所有的网页上都显示自己的图标,那就需要在你所有的模板上都加上这段代码,路径不要写错了。
其他类似问题
为您推荐:
提问者采纳
shortcut&rel=&image/gif&ico图片地址&/&&&ico图片地址&icon&shortcut&rel=&link&type=&&link&&image/x-icon&href=&href=&&type=&quot&&/&在你网站头部一般叫做header的文件中head标签之间添加这个代码;&icon&quot
提问者评价
互联网专家
ico图标的相关知识
其他1条回答
好吧,那我不会。应该有会的人
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 吻痕怎么快速消除 的文章

 

随机推荐