-
Notifications
You must be signed in to change notification settings - Fork 466
fix: Use hostname for graphql cache header url for varnish #2890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Dovid Levine <[email protected]>
justlevine
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: …