Skip to content

Speculative loading considerations #1157

@AntonyXSI

Description

@AntonyXSI

Bug Description

I have used prefetching on hundreds of WordPress sites for 5+ years with great success to CWV metrics and improving the user experience in general. Good to see this being explored. It's great a feature, however I don't believe that speculative loading would be suitable as an on by default core feature. Due to it having the ability to decrease scalability by increasing server resource usage, particularly for sites on shared hosting servers. It really needs to be configured depending on the site/server resources available therefore would be best suited as a plugin.

Happy to share what default settings has worked for the sites I use it on:

  1. Excluding logged in users. Prefetching really shines with page caching as the server is able to deliver the content almost instantly with near zero CPU usage without waiting for the page to be generated. Logged in visits are predominately dynamic non cacheable requests.

Using prefetching/prerendering on dynamic pages specifically on shared hosting where it can often take 1s+ for a page to be generated, would result in higher CPU usage and resources more easily bottlenecking. This is from pages being requested that may not be visited, as well as the ease/rate for links to be requested by hovering over them rather than manually when navigating through the site, and fundamentally the dynamic requests taking a lot longer. This affects the ability of the server to handle the same amount of traffic, and traffic spikes.

  1. Excluding URLs with query strings. This would solve needing to manually exclude the nonce, add to cart strings etc. Another example would be plugins using href links for filters, wishlists etc. These plugins don't always abide by the practice of adding the nofollow tag to links. Query parameters URLs are often excluded by page caching plugins as well. Including these would increase CPU usage and potentially cause undesirable actions (adding items to the cart on). A blanket exclude seems to be the best option to avoid compatibility issues with different plugins and custom code.

  2. Excluding links that contain "." or file extensions i.e to prevent a user from downloading large PDFs or images potentially bottlenecking bandwidth. An example would be images being wrapped in a link to the original uncropped image. Hovering over images in a gallery for example could result in lots of large unoptimized images being downloaded unnecessarily in the background. As images will begin to render almost instantly prerendering images, pdfs etc may not be as beneficial as prerendering pages. I'm also not sure what happens if .exe,.pdf or other large files are prefetched that would normally be downloaded once clicked? Does Chrome drop the request or continue the download from the same prefetch request? (Note: Excluding the uploads directory is implemented in Prevent speculatively loading links to the uploads, content, plugins, template, or stylesheet directories #1167.)

  3. Prefetching has the potential to double response times when PHP sessions are used, as PHP requests will be queued. For instance if a page might take 3s to be generated, hovering over 1 link then clicking another would result in that second link responding in 6s rather then 3s since the server has to wait for the first request to be processed.

Interested to hear your thoughts and if there might be a workaround for the above issues or if a more conservative setting would be suitable for the speculation rules unless otherwise configured?

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Plugin] Speculative LoadingIssues for the Speculative Loading plugin (formerly Speculation Rules)[Type] EnhancementA suggestion for improvement of an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions