Speed up response time #1813
-
Hello, can you please make response time faster? I tried in a blank WP with 10 products but time response up to 500ms :( |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 1 reply
-
@warcraft14115 not sure how you are implementing your data, have you tried apollo cache? take a look at https://www.apollographql.com/blog/graphql-caching-the-elephant-in-the-room-11a3df0c23ad |
Beta Was this translation helpful? Give feedback.
-
@warcraft14115 can you give some more info on the query you are making that is taking this long? Could you also let us know what version of the plugin you are on, and how you are making this query (ex. from the client, through WPGraphiQL, From another server, etc...). |
Beta Was this translation helpful? Give feedback.
-
@CodeProKid Is there a hook/filter which runs right before returning the response? I'd like to cache queries using transients api. I've looked all over docs and github but couldn't find anything. |
Beta Was this translation helpful? Give feedback.
-
Nvm, I just found out about |
Beta Was this translation helpful? Give feedback.
-
@dpacmittal did you ever try working on using |
Beta Was this translation helpful? Give feedback.
-
@izzygld I am using |
Beta Was this translation helpful? Give feedback.
-
can you share an example of how you are doing it? Are you wrapping the whole wpgraghql into a |
Beta Was this translation helpful? Give feedback.
-
@izzygld You should use https://github.com/valu-digital/wp-graphql-cache. If you still want to use a custom solution (like I did because I wanted to do stale-while-revalidate), here it is - https://gist.github.com/dpacmittal/e837e2a36714c6d1a279fbd5999debd0 |
Beta Was this translation helpful? Give feedback.
-
I'm going to transfer this to a Discussion. I think it's a good discussion and a lot of ways we can go about caching requests, but not an actionable issue on its own. |
Beta Was this translation helpful? Give feedback.
-
I wonder if there is any improvements on this as far as speed goes? |
Beta Was this translation helpful? Give feedback.
-
I wanted to follow up here as WPGraphQL v1.6.0 made a lot of performance improvements, that should help with most requests: See: https://github.com/wp-graphql/wp-graphql/releases/tag/v1.6.0 The best way to speed things up, however, is to reduce how much needs to execute in the first place. Making GET requests can help here, as it can take advantage of HTTP caching and never even hit the WordPress application layer. For example: In the screenshot we can see a GET request for a GraphQL query returning in This is faster than a REST request also for 10 posts on the same server, also using GET, also with Cache Control set. Often, WPGraphQL will be faster than REST because there's less data to download. But if you're comparing GET requests to a REST endpoint with POST requests to a GraphQL endpoint, then yes, GraphQL will be slower because you're always making the full trip to the server, and not able to take advantage of the HTTP caching. Solutions like WP GraphQL Cache from Valu Digital are a good step toward making POST requests respond faster as it eliminates a lot of underlying execution. We're working on some things in this area that should benefit all WPGraphQL users in the near future, so stay tuned for updates! |
Beta Was this translation helpful? Give feedback.
-
will redis caching work? |
Beta Was this translation helpful? Give feedback.
@izzygld You should use https://github.com/valu-digital/wp-graphql-cache. If you still want to use a custom solution (like I did because I wanted to do stale-while-revalidate), here it is - https://gist.github.com/dpacmittal/e837e2a36714c6d1a279fbd5999debd0