如何从PHP中的浏览器检测prefetching? [英] How to detect prefetching from the browser in PHP?

查看:137
本文介绍了如何从PHP中的浏览器检测prefetching?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有些可以通过浏览器pfetched $ P $(见的这个或<一个href=\"http://word$p$pss.stackexchange.com/questions/83656/word$p$pss-tries-to-load-next-page-after-done-loading-current-page\">that).如何在PHP中检测到一个请求是prefetched请求?

Some pages can be prefetched by the browser (see this or that). How to detect in PHP that a request is a prefetched request ?

有没有什么方法是不特定浏览器?

Is there any method is not browser-specific ?

(PS:我使用Apache)

(PS: I use Apache.)

推荐答案

我一直在寻找一个类似的答案停止FF等浏览器抛出我的服务器端页面数。

I was looking for a similar answer to stop FF and other browsers throwing out my server side page counts.

  • Firefox
  • Chrome white paper

根据上述文章,火狐发送一个报头,这使得它易于检测,但铬白皮书指出Chrome不给出任何指示给服务器。在Chrome白皮书指出,当他们使用的<一个外部的分析解决方案(用JS脚本)则不会计入prefetch命中href=\"https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API\"相对=nofollow>页知名度API 。

According to the articles above, Firefox sends a header which makes it easy to detect but the Chrome white paper states that Chrome doesn't give any indication to the server. The Chrome white paper notes that external analytic solutions (scripts written in JS) will not count the prefetch hits when they use the page visibility API.

我的建议是写自己的JS脚本,如果页面是不断可见检测。

My suggestion is to write your own JS script to detect if the page is ever made visible.

这篇关于如何从PHP中的浏览器检测prefetching?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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