2

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.

1
  • Your server would have to detect a pattern. I seriously doubt it can be done from client-side code. Firefox sends a header when it prefetches ("X-moz: prefetch"). Commented Mar 21, 2011 at 19:51

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

I'll 2nd the opinion that the client probably can't do it. One possible solution is to add a prefetch to a page that signifies pre-fetching is enabled, e.g.:

<link rel="prefetch" href="/hasPrefetching.php"> 

If you need to know on the server, you now have the info. If you need to know on the client, you can poll for it after a while.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.