浏览器不请求favicon.ico的原因是什么? [英] What are the reasons that a browser would not request favicon.ico?

查看:277
本文介绍了浏览器不请求favicon.ico的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个位于服务器根目录的简单网页,带有一个位于"/favicon.ico"的快捷方式图标,但是我的浏览器从未请求过此favicon.ico.我在html中添加了以下内容:

I am writing a simple webpage located at the root directory of the server with a shortcut icon located at "/favicon.ico", but my browser never requests this favicon.ico. I have included the following in the html:

<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />

当我打开开发人员工具的网络"标签时,看到了对192.168.0.1(网页本身)的请求,但是没有随后的图标请求.清除缓存并启用禁用缓存"并不能改变行为.

When I open up the network tab of the developer tools, I see the request for 192.168.0.1 (the webpage itself), but no subsequent request for the icon. Clearing the cache and enabling "disable cache" does nothing to change the behavior.

开发者控制台中没有出现任何错误,其他所有内容似乎都可以正常工作.

There are no errors appearing in the developer console and everything else seems to be working fine.

我按照让·弗朗索瓦(Jean-Francois)的帖子将链接更新为以下内容,但仍然存在相同的问题:

I updated the link to the following as per the post by Jean-Francois and was still having the same issue:

<link href="favicon.ico" rel="icon" type="image/x-icon"/>

推荐答案

解决了我处理图标缓存以及检测浏览器是否实际上在请求图标的方式的问题.

Turns out the issue I had dealt with the caching of the icon as well as the way that I was detecting if the browser was actually requesting the icon.

我只是查看chrome上的网络日志,以确定是否有对favicon.ico和

I was just looking at the network log on chrome to determine if there was a request going out for favicon.ico and Favicon request not showing in network tab of developer toolbars shows that there is an issue with this.

仅进行强制刷新(通过强制浏览器不使用缓存)似乎也无法解决该问题,而我能够使所有三个浏览器都发出请求的唯一方法是添加查询参数到链接的末尾.最终的链接标签为:

And just doing hard refreshes (by forcing the browser to not use the cache) did not seem to fix the issue either, and the only way that I was able to get all three browsers to make the request was to add a query parameter to the end of the link. The final link tag was:

<link href="favicon.ico?v=1.0" rel="icon" type="image/x-icon"/>

这篇关于浏览器不请求favicon.ico的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆