用于检测 Google Chrome 的预加载请求的 HTTP 标头 [英] HTTP header to detect a preload request by Google Chrome

查看:54
本文介绍了用于检测 Google Chrome 的预加载请求的 HTTP 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Chrome 17 引入了一个新的功能在实际发出请求时预加载网页以提高渲染速度(在多功能栏中按 Enter).

Google Chrome 17 introduced a new feature which preloads a webpage to improve rendering speed upon actually making the request (hitting enter in the omnibar).

两个问题:是否有一个 HTTP 标头来检测服务器端的此类请求,如果确实存在,那么正确的响应是什么以防止此类预加载(以防止可能产生不良影响的意外请求)?

Two questions: Is there a HTTP header to detect such a request on server side, and if one actually exists what is the proper response in order to prevent such preloading (to prevent unintended requests which might have unwanted effects)?

谷歌浏览器是否会在发出预加载请求之前检查 robots.txt?是否有仅针对此特定行为的 robots.txt 设置?(我想/希望不允许已经有效).

Does Google Chrome check the robots.txt before making preload requests? Is there a robots.txt setting which targets only this specific behaviour? (I supose/hope disallow already works).

是否有元标记通知谷歌浏览器不再在当前域上预加载?

Is there a meta tag to inform Google Chrome to never preload again on the current domain?

推荐答案

当 Firefox 预取内容时(根据引用页面的要求标记),它会随请求发送以下标头:X-moz:预取

When Firefox pre-fetches content (at the behest of the referrer page’s markup), it sends the following header with the request: X-moz: prefetch

Safari 的做法类似,使用:X-Purpose:预览.根据这个票,Chrome 也是.

Safari does similarly, using: X-Purpose: preview. According to this ticket , Chrome does, too.

对于预渲染,Chrome 不会向客户.相反,必须在 JS 中使用 Page Visibility API

For pre-rendering, Chrome does not send any header whatsoever to the client. Instead, one must use the Page Visibility API, in JS

来源补充阅读

这篇关于用于检测 Google Chrome 的预加载请求的 HTTP 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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