Skip to content

GraphQL Lacking Stale Content Delivery Time Implementation #559

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

Closed
AntonEvers opened this issue Aug 18, 2022 · 4 comments · Fixed by #561
Closed

GraphQL Lacking Stale Content Delivery Time Implementation #559

AntonEvers opened this issue Aug 18, 2022 · 4 comments · Fixed by #561

Comments

@AntonEvers
Copy link

AntonEvers commented Aug 18, 2022

As a GraphQL consumer using Fastly I want to receive stale content for a specific amount of time after cache invalidation so that I get fast responses more often and so that I do not have to wait for a slower origin request every time cache is invalidated, also in case of server failure.

AC

  • stale-while-revalidate will be sent in GraphQL response header cache-control from Adobe Commerce
  • The value of stale-while-revalidate will be equal to the configuration field full_page_cache/fastly/fastly_advanced_configuration/stale_ttl titled Stale Content Delivery Time
  • stale-if-error will be sent in GraphQL response header cache-control from Adobe Commerce
  • The value of stale-if-error will be equal to the configuration field full_page_cache/fastly/fastly_advanced_configuration/stale_error_ttl titled Stale Content Delivery Time in Case of Backend Error
  • This functionality should work the same as \Fastly\Cdn\Model\Layout\LayoutPlugin::afterGenerateElements but then for GraphQL requests.

Approved Schema

  • none

Technical direction

Recommendation to build this as a plugin to \Magento\Framework\App\Response\Http::setPublicHeaders, right after \Magento\GraphQlCache\Controller\Plugin\GraphQl::afterRenderResult is called.
See vendor/magento/module-graph-ql-cache/etc/graphql/di.xml as example:

<type name="Magento\Framework\App\FrontControllerInterface">
    <plugin name="graphql-dispatch-plugin" type="Magento\GraphQlCache\Controller\Plugin\GraphQl"/>
    <plugin name="front-controller-builtin-cache" type="Magento\PageCache\Model\App\FrontController\BuiltinPlugin"/>
    <plugin name="front-controller-varnish-cache" type="Magento\PageCache\Model\App\FrontController\VarnishPlugin"/>
</type>

Note that this plugin only applies to the GraphQL area.

dpotkoc added a commit to favicode/fastly-magento2 that referenced this issue Aug 23, 2022
@vvuksan
Copy link
Contributor

vvuksan commented Aug 25, 2022

Released in 1.2.186.

@AntonEvers
Copy link
Author

@vvuksan please see my comments on the commit, this PR is only half the solution to the mentioned problem, as stale-if-error is still missing.

@dpotkoc
Copy link
Contributor

dpotkoc commented Aug 29, 2022

@AntonEvers stale-if-error will be added.

@vvuksan
Copy link
Contributor

vvuksan commented Aug 29, 2022

This has been released in 1.2.187.

MickaelDatadome pushed a commit to DataDome/fastly-magento2 that referenced this issue Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants