wp-graphql/wp-graphql-smart-cache

The plugin has stopped serving queries from disk cache on initial page load

Opened this issue · 8 comments

Hi there, an issue arose just now where my graphQL queries are not being served form cache on the server side anymore the first time the page is loaded. If I reload the page then the query loads.

I've purged my cache and done this repeatedly to the same queries but the problem persists.
It was consistently serving from cache just yesterday

Hey @WintersInstruments can you please clarify the behavior that you expect? You've stated that you've purged your cache repeatedly and that the query is not being served from cached, however this feels like expected behavior.

If you can please provide more information on what your expectations are, and the steps for us to try and reproduce, we can try to help you better.


Things to consider with cache:

  • If the request is authenticated, it will bypass cache (i.e. logged into WordPress in one tab and testing your GraphQL query in another tab)

  • The cache key for a query is made up of both the query AND the variables.
    For example, the combination of the following query and variables will be cached uniquely:

    { "id": 1 }
    { "id": 2 }
    query GetPostById($ID: ID!) {
      post(id: $ID) {
        id
        title
      }
    }
  • Manually purging cache will lead to more cache misses

Hi there, I took another look at the problem and it appears the issue is actually the OPTIONS preflight is taking way too long.

Header set Access-Control-Allow-Origin: //url here Header set Access-Control-Allow-Methods "GET, OPTIONS" Header set Access-Control-Allow-Headers "Content-Type, Authorization" Header set Access-Control-Max-Age "86400"

On initial load this continues to be extremely slow.

Hey @WintersInstruments, can you please share what version of WPGraphQL Smart Cache & WPGraphQL (and any other possibly relevant plugins) you are using?

Hi @josephfusco

I'm using WPGraphQL 1.28 and WPGraphQL Smart Cache 1.3.2

Also WpGraphQL for ACF
WP .htaccess editor
Post Types Order
Image optimization by optimole
Headless mode
Firebird Lite
Category Order and Taxonomy Terms Order
ACF
ACF Photo Gallery Field

Thanks for the info! If you use Postman or a similar standalone client, are you still experiencing the slowness with the options preflight?

Hi Joe, when I run the query in postman with an OPTIONS method it's coming back at 614ms
image

Have you noticed any performance improvements after deactivating other plugins? I would love for us to get this narrowed down to a specific plugin if possible.