favicon 404 是否影响性能
我们注意到 Coldfusion CFIDE 服务器监视器中抛出了大量 404 错误,我们花了一段时间才发现缺少图标等原因导致了这些错误。
我们使用自定义 404 模板页面,其中包含一些逻辑(不仅仅是基本的 HTML)。因此,每当出现网站图标 404 错误时,就会生成这些页面并将其返回给用户。
由于许多浏览器默认都会请求这些图标(如果标头中没有指定图标,则会在站点根目录或类似的位置中查找),因此它会在我们的服务器上抛出大量 404,这也会消耗处理时间作为传输带宽。我们的服务器在大多数情况下运行良好,但当它确实受到大量使用时,有时会出现重大性能问题。
我知道这是一个性能问题,但是是否足以保证尝试解决此问题?如果是这样,是否有办法使用 Coldfusion 服务器(或运行 IIS 的底层 Windows Server 2003)来过滤哪些文件实际引发 CF 404 错误?理想情况下,对于像这些图标、CSS 和 Javascript 这样的文件(因为访问者永远不会真正“看到”这些文件的输出),我们只想返回一个没有内容的 HTTP 404 响应,因为它是不需要的......
We have been noticing a lot of 404 errors being thrown in our Coldfusion CFIDE server monitor, and it took us a while to find out that things like missing favicons are causing these errors.
We use a custom 404 template page, which contains some logic to it (more than just basic HTML). So, whenever a 404 for a favicon occurs, these pages are generated and returned to the user.
Since these favicons are requested by default on many browsers (if there is no in the header that specifies one, it looks in the site root or something like that), it's throwing massive amounts of 404s on our server, which costs processing time as well as bandwidth for delivery. Our server runs fine most of the time, but when it does get some heavy usage, we can sometimes have major performance problems.
I know that this is a performance issue, but would it be enough of one to warrant trying to fix this? If so, is there a way with the Coldfusion server (or our underlying Windows Server 2003 running IIS) to filter what files actually throw a CF 404 error? Ideally, for files like these favicons, CSS, and Javascript (since a visitor never really "sees" the output of these), we would simply want to return an HTTP 404 response with no content, as it is unneeded...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,缺少网站图标确实会影响性能,当您拥有自定义 404 页面时(特别是如果 404 页面由内容管理系统处理),任何缺少的内容也会影响性能。这是因为每次浏览器请求文件(图像、视频、页面等)时,都会导致服务器负载。假设您网站的每个页面上都缺少图标。如果您的 404 页面是内容管理系统的一部分,这会使服务器上的负载增加一倍(基本上每次请求 2 个页面,而不是 1 个)。如果您的 404 页面不同,但仍然具有逻辑,这会增加负载,但仅限于文件所需的负载(较少的逻辑 = 较少的负载,反之亦然)。
我建议解决此问题,但不一定是通过终止某些扩展的自定义 404 页面。在我看来,如果您只是向所有网站添加一个网站图标文件(对于您和您的访问者而言)会更好。这不仅可以解决您的 404 问题,还可以帮助您的访问者在为页面添加书签或将网站添加为应用程序选项卡时更快地识别您的网站(即使您的网站不向公众开放,这也适用,因为后端站点是应用程序选项卡的一个很好的用例)。除了服务器性能之外,下载 404 页面也会影响服务器端和最终用户的网络性能。 404 页面也可能不会被缓存,即使有,也可能不会像现有的图标一样长,这会导致请求发生的频率比您简单创建图标时要频繁得多。
如果您不想花时间(或不需要)进行高级品牌推广(例如为网站图标创建自定义徽标),则可以使用带有字母(例如“K”)的基本图像做。网站图标对于公众、任何员工甚至您自己都非常有用,所以我想说绝对值得您花时间至少做一个基本的网站图标。
Yes, missing favicons do affect performance, as does any missing content when you have a custom 404 page (esp. if the 404 page is handled by a content management system). This is because every time the file (image, video, page, etc) is requested by the browser, it causes load on your server. Let's say the favicon is missing on every page of your website. If your 404 page is part of your content management system, this doubles the load on your server (basically requesting 2 pages every time instead of 1). If your 404 page is different, but still has logic, this increases the load, but only as much as the file requires (less logic = less load, and vice-versa).
I would suggest fixing this issue, but not necessarily by killing custom 404 pages for certain extensions. In my opinion, it would be better (for you, and your visitors) if you simply added a favicon file to all of your sites. Not only would this solve your 404 issue, but it would help your visitors to recognize your website quicker when bookmarking pages, or adding the site as an App Tab (which would apply, even if your site isn't available to the public, as backend sites are a great use case for App Tabs). Aside from your server's performance, having to download the 404 page causes for network performance as well, both on your server's end as well as the end-user. The 404 page may also not be cached, and even if it is, probably not for as long as an existing favicon would be, which causes the request to happen far more often than it would if you simply created a favicon.
If you don't want to take the time (or don't have a need) to do advanced branding (such as creating a custom logo for the favicon), a basic image with a letter on it (e.g. "K") will do. Favicons are extremely useful for the public, any staff, and even yourself, so I would say it's definitely worth your time to at least do a basic favicon.
只有您才能真正判断问题是否足以保证修复...每秒生成多少次 404,它们会给服务器带来多少额外负载等等。
关于修复...为什么不呢只需部署一个网站图标?这可能比担心问题要快。
Only you can really judge if its enough of a problem to warrant fixing... how many times per second are the 404's generated, what additional load do they put on the server, etc.
Regarding a fix... why don't you just deploy a favicon? It would probably be quicker than worrying about the problem.
正如其他人提到的,我认为处理这个问题的最简单和最明智的方法不是尝试在 404 处理方面处理它,而只是确保 404 不会首先出现地方。如果这一切都是因为缺少网站图标而发生的...通过不缺少网站图标来修复它!如果您没有资源或没有意愿适当地打造品牌,只需使用通用品牌即可。解决实际问题比解决问题症状更好。
As someone else touched on, I think the easiest and most sensible way of dealing with this problem is not to try to deal with it at the 404-handling side of things, but rather just make sure the 404 doesn't occur in the first place. If this is all happening because of missing favicons... fix it by not having missing favicons! If you don't have the resources or desire to brand one appropriately, just use a generic one. It's better to treat the actual problem than a symptom of the problem.