headless-wp-starter icon indicating copy to clipboard operation
headless-wp-starter copied to clipboard

page navigation is slow

Open geocine opened this issue 6 years ago • 11 comments
trafficstars

Do you have any idea why the page navigation is slow? React frontend using client side routing should navigate instantaneously.

Currently the average page load of this setup is 600-700ms. Using WordPress on a normal setup, you will still be able to achieve less than 250ms loading speeds. Am I missing something here?

Imgur

geocine avatar Jan 31 '19 16:01 geocine

My experience is similar, but only the first time I go between pages (with a cleared cache) its 400-600ms. After that, it’s faster, at 150-300ms, although it’s rather inconsistent. Going back and forth between e.g. Sample Post and Home can vary 150ms, which doesn’t make much sense to me.

Is yours slow the second time you click through or only the first time?

I worry most about how it performs in actual production, which I haven't tried yet. I assume production build is faster.

Can anyone else chime in on this? Anyone using this in production?

TechStacker avatar Jan 31 '19 22:01 TechStacker

No matter if the page is cached or not, it is still get the same results. Sometimes it even reaches 800ms

geocine avatar Feb 01 '19 00:02 geocine

This is one of the head aches with headless WP. I recommend for production using memcache, and use WPGraphQL. The reason of the load time is because WP is bootstrapped on each request, so WP, the plugins, and themes are loaded on each call. I hope this helps in understanding why the long load times.

jacobmishkin avatar Feb 04 '19 21:02 jacobmishkin

Appreciate your info @jacobmishkin

It’s a bit of a bummer since performance was the main reason I got excited about this kit. I haven’t seen any performant examples in production. I know that Kata.ai also uses Next+WP (their own version) but their website is pretty slow :-/

I guess if you want blazing fast site Headless WP, Gatsby is a better option.

But I’ll check out Memcache, thanks for the tip!

TechStacker avatar Feb 12 '19 14:02 TechStacker

I did end up using Gatsby

geocine avatar Feb 14 '19 09:02 geocine

This PR introduces a GraphQL frontend: https://github.com/postlight/headless-wp-starter/pull/187 I am also looking into ways to improve performance of the non-graphql frontend. Once this PR is ready, it will be merged, shouldn't take more than a week. @geocine @jacobmishkin

alexiakl avatar Feb 14 '19 09:02 alexiakl

@alexiakl that sounds awesome, thank you!

TechStacker avatar Feb 14 '19 09:02 TechStacker

@geocine the API Accelerator plugin will speed things up.

This could also be implemented for GraphQL requests by doing a check:

if ( defined( 'GRAPHQL_REQUEST' && true === GRAPHQL_REQUEST ) {
  // do something
}

cr101 avatar Feb 14 '19 10:02 cr101

Ok, so the page load is slow because you're running it in development mode. In production, you will get significant improvement in page load: You can try it: In package.json inside frontend folder, add to scripts the following:

"prod_start": "NODE_ENV=production node server.js"

And in docker-compose.yml, edit the first command line to be:

    frontend:
        command: bash -c 'yarn && yarn build && yarn prod_start'

After that, delete the frontend container, and run docker-compose up -d

alexiakl avatar Feb 14 '19 16:02 alexiakl

@alexiakl How to run the site in production mode is an essential piece of information and needs to be in the documentation. Thanks for the tip.

cr101 avatar Feb 15 '19 00:02 cr101

There are multiple things at play here. We get sub 60ms response times on our production server. Development is allot slower.

  • Requests for things such as menu items that rarely change should be cached.
  • Production build of Next is allot faster
  • Production build of wordpress is allot faster

andrewmclagan avatar Oct 21 '19 23:10 andrewmclagan