Performance implications

Created on 23 November 2024, 11 days ago

I didn't want to hijack the other issue because I believe this issue will be a bit in a different direction. I also don't know what category this issue will be since it's not technically a bug but a bit of an information issue so I put it into plan :)

So I'm using Quicklink module for a long time and I love it. For not so big scale websites it gives a smother experience in general.

But what needs to be understood is that this module is prefetching all the links that are visible on the current viewport (including hidden links with css). So if you have a landing page with a sitemap-like heavy menus like a megamenu etc, it will prefetch all the links in the menu etc.

So with that knowledge and with our testing we saw high CPU usage when the quicklink module is active and even causing max_user_connection errors at some point. Because we suspected that every prefetch is actually bootstrapping drupal in the background or at least doing database connections every time.


Here we can see the difference between the module active and the higher CPU usage and the lower usage when it's disabled.

We are still monitoring if the max_user_connection error is related to this high usage since we are not 100% sure yet. But so far we didn't see any of those eighter.

So if your site is on a shared hosting with limited resources and have a link heavy website you should be careful using this module.

Other than that if you have plenty resource or not that much heavy linked pages this module is perfect for a smoother surf experience for the visitor.

As of a plan; maintainers could consider to limit the number of links to prefetch maybe. Or change the prefetching strategy in some ways (not sure how, not much of a pro coder :)

🌱 Plan
Status

Active

Version

2.0

Component

Miscellaneous

Created by

🇹🇷Turkey rgnyldz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • 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.

Production build 0.71.5 2024