The dangers of using HTML5 prefetch?

Good, so this is not a big concern, as it is only supported by a few browsers:

  • Mozilla Firefox: Supported
  • Google Chrome: supported since version 13 (use alternative syntax)
  • Safari: Internet not currently supported
  • Explorer: not currently supported

However, prefetching makes me twitch. If a user lands on your page and bounces to another site, have you paid for the bandwidth of them visiting your prefetch links?

Is there a risk that developers pre-load each link to a page, which in turn will make the site slower for the user?

It seems like this could change analytics. Will people force users to browse pages using prefetching?

Security, you do not know which pages are preloaded. Can it prefix malicious files?

Will this prefetch be painful for limited use mobile users?

+6
source share
2 answers

I cannot call myself an expert on this issue, but I can make the following observations:

  • Prefetching should only be considered where it is known to be useful. Enabling prefetching in everything would be just plain stupid. This, in fact, is the load balance of the server and the user.

  • I did not study the HTML5 prefetch specification, but I would suggest that they provide a heading that says "this query is executed as part of the prefetch", which can be used to fix the analytics problem - if it is a prefetch, do not enable it analytics statistics. "

  • From a security point of view, one would expect prefetch to follow the same cross-domain network rules as Ajax. This will reduce any cases where XSS is a problem.

  • Mobile browsers that support HTML5 prefetching must be smart enough to turn it on when using WiFi and turn it off when using potentially expensive or slow forms of network connectivity, for example. 2G / 3G.

As I said, I cannot guarantee any of the above, but (for example, with any technology) is an example of best practice. You would not use Cache-Control to force every page on your site to cache for a year. You also did not expect the browser to satisfy the cross-domain Ajax request. Hopefully the same considerations were adopted for prefetching.

+8
source

To answer the question of analytics and statistics, the specification has the following meanings:

In order to ensure compatibility and increase the success rate of preliminary request requests, the landing page can use [PAGE VISIBILITY] to determine the visibility status of the page as it is created and implement the appropriate logic to avoid actions that may cause the prerender (for example, non-idempotent requests ) or unwanted side effects from starting (for example, beacons that run before the page is displayed).

+1
source

Source: https://habr.com/ru/post/901518/


All Articles