-
Notifications
You must be signed in to change notification settings - Fork 82
Support for WP REST Cache #1630
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
base: trunk
Are you sure you want to change the base?
Conversation
Proper cache invalidation will be the biggest challenge. New posts, new comments, user meta updates, blog user option updates, etc. It would also be nice if we could avoid blanket-invalidating all cached ActivityPub endpoints for all of these, and be more targeted. |
So we need to keep track of any change regarding any of the endpoints? Also, do we need to check whether the change does actually change the API endpoint response or should we always invalidate the cache when it might change the response? I guess we currently have no decorated list of changes we need to look for? |
Looking a bit more at the plugin, I think we'll have to be pretty broad about invalidating caches. Most of the endpoints are user/actor-based, and WP REST Cache doesn't have a concept for that. It's post type and post_id, and that seems to be pretty much it. I think your approach of defining a custom type and invalidating all associated endpoints is probably the safest. |
Need to do a bit more testing before this is ready for review. |
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.
Pull Request Overview
Adds integration with the WP Rest Cache plugin to allowlist ActivityPub endpoints and invalidate caches when posts or comments change.
- Checks for the WP Rest Cache plugin in
integration/load.php
and initializes the integration. - Introduces
Activitypub\Integration\WP_Rest_Cache
to register allowed endpoints, set cache metadata, and flush caches on status transitions.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
integration/load.php | Plugin existence check and call to initialize the WP Rest Cache hook |
integration/class-wp-rest-cache.php | New class registering filters/actions for caching ActivityPub routes |
Comments suppressed due to low confidence (2)
integration/class-wp-rest-cache.php:1
- No unit or integration tests were added for this caching integration. Consider adding tests to verify allowed endpoints, object type settings, single-item logic, and cache invalidation on status transitions.
<?php
integration/load.php:126
- The call to WP_Rest_Cache::init() will fail without importing or fully qualifying the Activitypub\Integration\WP_Rest_Cache class. Add
use Activitypub\Integration\WP_Rest_Cache;
at the top or call\Activitypub\Integration\WP_Rest_Cache::init()
.
if ( class_exists( 'WP_Rest_Cache_Plugin\Includes\Plugin' ) ) {
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
See https://wordpress.org/support/topic/caching-activity-pub-endpoints/
See https://epiph.yt/en/blog/2025/accidental-ddos-through-activitypub-plugin/
Proposed changes:
Other information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Added support for the WP Rest Cache plugin to help with caching REST API responses.
/cc @MatzeKitt