-
Notifications
You must be signed in to change notification settings - Fork 808
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
REST API: Add persistent caching to Comments Count endpoint #41545
base: trunk
Are you sure you want to change the base?
Conversation
The WPCOM_JSON_API::wp_count_comments() did not have any caching mechanism. This caused noticable loads when many requests to this endpoint happen in a short period of time on WPCOM. This change adds a caching method similar to that used in core's get_comments() function.
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryNo summary data is avilable for parent commit e629b29, cannot calculate coverage changes. 😴 If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, you might try re-running the Tests / Publish coverage data job on this PR once the corresponding job on the trunk commit has succeeded. |
As discussed in #40587, the Comments Count endpoint does not offer use any caching layers. For some sights with large amounts of comments, this can lead to repeated high-cost queries when making multiple requests to this endpoint in a short amount of time.
This PR adds persistent caching support to this endpoint. This caching is limited to just sites that add a persistent cache plugins. Since the biggest sites and sites on managed platforms are likely to use such a plugin, we'll see some immediate benefit from this change. Further discussion will determine the best path forward to ensure that all sites (with or without a persistent cache plugin) can benefit from caching.
Fixes #40587
Proposed changes:
WP_Object_Cache
to data handlers for the Comments Count REST API endpoint.Other information:
Jetpack product discussion
Discussion in originating issue.
Does this pull request change what data or activity we track or use?
No.
Testing instructions: