- Issue created by @rgnyldz
- 🇷🇺Russia niklan Russia, Perm
Hi, I think your concerns are already covered by these settings:
You also have the option to ignore links that use specific CSS selectors. If you hide links with CSS, consider using a class like "visually-hidden" and adding it to this option. In this case, they will not be pre-fetched.
It is also possible to use selectors such as
:not(.prefetch)
to disable pre-fetching for anything except links with the prefetch class, allowing you to control what should be pre-fetched and what shouldn't. For example, product pages on an e-commerce site.Also, it is better to set the 'Cache-Control' setting with this module enabled. In this way, the pages that the user has already visited will be pre-fetched from the memory cache instead of making a request to the server.
I agree that these module and library should be used with caution, as they are not a silver bullet and will not magically improve performance. They do have their drawbacks and should be used wisely. If your website consists primarily of static pages without user sessions, this is a great tool to improve overall page responsiveness to user actions. With the right Drupal setup, all these issues are minor for most hosting providers.
- 🇹🇷Turkey rgnyldz
Thank you @niklan I totally missed these options in the settings page. I will try to fiddle with them more.
I'm still not sure about the analytics differences since it doesn't make sense that these prefetches to register as a different user. I guess I'll try to set up a copy of the server and site to do some testing.
Still I agree that this module is probably the closest to a silver bullet for non-session websites. :)
- 🇷🇺Russia niklan Russia, Perm
It's just my assumption, but I don't think it can affect Google Analytics in any way. Prefetching is basically loading the HTML page from the server. Since Google Analytics is a client-side library, it will not run until the page has been rendered. Also, I seriously doubt that Google Analytics treats prefetches in any way, because they can be easily detected. Not only do they use a special link format, but they also include a request header with "Purpose: prefetch". Not to mention, the library itself is built and maintained by Google. If that were the case, they would surely mention it on their repo. I think it is just coincidence.
But, as far as I understand, the library itself (not the Drupal module) can work with the Speculation Rules API. In theory, this could cause an issue because it can also prerender pages, instead of simply preloading, and pre-rendering also means that some JavaScript might be executed. (But I'm not sure; I haven't dug into it too deeply.)
You might want to check the Speculation Rules on the website. They can be in the response headers or on the page.
<script type="speculationrules">…
Speculation-Rules: "…."
If you are using Cloudflare or a similar service, please double-check that. For example, Cloudflare has an option called "Speed Brain" which is essentially the Speculation Rules API.
Knowing that Quicklink (library) can interact with speculative rules, and it can render pages in the background, this could be a problem in theory that affects Google Analytics statistics.