GraphQL works as a query language posting always against a single end point. So most caching tools can't be used. So is network caching completely impossible with GraphQL? Is client side caching the only possible way to cache? Or is there a workaround?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
When using HTTP transport for your GraphQL API you can cache the HTTP responses just like any other HTTP traffic. Typically the CDN will hash the full request and then cache the response with that hash. When the same request comes in next time it won't connect to your GraphQL server, it will just respond with the cached results.
The challenge with GraphQL is that it's traditionally sent via POST, which is not supported by many CDNs. You can either use GET with a normal CDN (Fastly, Cloudflare, Cloudfront), or you can use a GraphQL specific CDN (FastQL).
Full disclosure: I built FastQL after running into this issue.