I recently received a request to determine if a user’s browser has pre-fetching enabled. I’ve searched around, but I’ve come up empty. Any thoughts on how to accomplish this task? I’ve watched traffic in the header and I don’t see anything in the request that would indicate pre-fetching has been enabled.
I recently received a request to determine if a user’s browser has pre-fetching enabled.
Share
Put
<link href="myTester.xxx" rel="prefetch" />in the head.In whatever handles for myTester.xxx (which would hence more likely by myTester.php, myTester.aspx, etc.) set a flag in the session (if you’re already using sessions and hence there’s no more penalty for doing so) or set a cookie. Make the response v. small (empty would be fine).
On onload, set a delayed (use
setTimeout) attempt to retrieve an XML or JSON file from myTesterResult.xxx which has a different result depending upon that session value or cookie.Alternatively, if you don’t need it to be reacted to on that page, there’s no need for any client-side script at all, subsequent server-side script will be able to use the session or cookie as appropriate.