Mozilla Firefox prefetching rel=“next”
문제
Firefox appears to prefetch anything that is set in a meta tag like so:
<link rel="next" href="http://domain.com/page/2">
More can be read about this here: http://developer.mozilla.org/en-US/docs/Link_prefetching_FAQ
Now on my site, when there are multiple pages for things like comments i've been using rel="next" and rel="previous", as I thought this was good mark up and may be used to help certain readers or search engine bots.
However i've also been trying to track what the last comment a user read was, but this hasn't been working (one of those stupid times when you spent hours on something simple).
Basically, when a user reads page 2 of 3 for instance, I update the database to say they've read page 2, but not page 3. However because page 3 gets prefetched, the code for that page runs and an SQL update fires for that page as well even though the user has never actually read page 3.
So really I have a few questiosn:
- Is there a way I can avoid this while keeping the "next" and "prev" mark up? Or is it easier to just remove those meta tags?
- Are there any other forms of prefetching that I should know about and try and deal with?
- Is there is a special way to tell if something is just a prefetch such as a special request header?
해결책
Answers to your question, in order:
- Sort of. You can throw a
?something
on the ends of your URIs to make them not prefetchable, I think. - Almost certainly. Chrome does various prefetching stuff too, and the
?something
trick may not work there. - Yes. See https://developer.mozilla.org/en-US/docs/Link_prefetching_FAQ#As_a_server_admin.2C_can_I_distinguish_prefetch_requests_from_normal_requests.3F in the FAQ you linked to.