fix: Use hostname for graphql cache header url for varnish#2890
fix: Use hostname for graphql cache header url for varnish#2890jasonbahl merged 5 commits intowp-graphql:developfrom
Conversation
Co-authored-by: Dovid Levine <justlevine@gmail.com>
justlevine
left a comment
There was a problem hiding this comment.
LGTM 🚀
The lockfile version changes included here are explicit in #2891, so i'm not concerned that they slip in here too.
fix per phpcs
|
Code Climate has analyzed commit 5649e04 and detected 0 issues on this pull request. View more on Code Climate. |
|
@markkelnar we might need to revert this. The full endpoint is returned to allow for multi-tenant caches to not accidentally purge the incorrect thing. see: varnish/varnish-modules#41 (comment) For WordPress instances that are set up as sub-directory multisites ( If we use the X-GraphQL-Url to prefix our keys, and the value is only the host, not the full endpoint, then we could have collisions. For example a query from Currently they would be tagged as When a post in site 1 changes, it would then purge If we go back to just the host, instead of the full endpoint, then we end up tagging both as: If we expand to a multisite network of hundreds of sites that each have I believe, unless I'm missing something about how Varnish + XKey, etc works, I think we probably need to keep the full endpoint here. Some more context:
|
|
I see site_url() used in graphql_get_endpoint_url(). We should confirm that is indeed returning the value for public/queryable hostname/path, ex. domain.com/pathy/graphql/, that you are expecting and not the path to wp-admin path. We might want to use home_url() instead for the url of where requests are sent. It might also make sense not to include the protocol (http/https) in the url cache header. Without knowing those, we might not have a change in behavior for anyone using caching. If you are more comfortable reverting out this change and figuring that out before we try again, we can do that. |
|
@markkelnar I set up a multisite using localwp and set it to use sub-directories. My site is cleverly named I created a 2nd site, cleverly named When I query data from site-2, the expected fully qualified endpoint is output in the headers: I believe we will cause a regression for subdomain multisites if we make this change. |

What does this implement/fix? Explain your changes.
The graphql url cache key header returned includes http/https as well as path. But this differs from integration with WPE Varnish cache, where this currently runs. Bring this to consistent/expected behavior where the varnish rule uses and invalidates only the hostname.
Does this close any currently open issues?
part of wp-graphql/wp-graphql-smart-cache/issues/246
Any relevant logs, error output, GraphiQL screenshots, etc?
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
Any other comments?
…
Where has this been tested?
Operating System: …
WordPress Version: …