Hi! Is possible to cache custom taxonomy requests dispatched by Gutenbergs Metaboxes? I tried to add “wp/v2/brand” at Global cacheable request headers setting, but do not get any requests in the Endpoint API Caches list.
]]>LS Cache as I’m sure several other cache plugins out there has a setting to Cache REST API (Cache requests made by WordPress REST API calls)
I’m wondering both do the same function and whether if there benefit or no need to have both ?
Dear plugin team, first of all, a million thanks for this terrific plugin! We’ve only seen positive results whenever we deploy it.
Would you consider adding the option to define certain plugin settings in the wp-config? This simplifies deploying the plugin programmatically and enables settings to be locked to anyone without file editing rights.
I did some grepping in the latest plugin release and from what I can tell, there’s no place where global constants are read, but I may have missed something.
If you consider giving this feature a go, we could provide a MR.
All the best and thanks again!
]]>Whilst testing this useful plugin, we find that a request to a default endpoint (ie GET /wp-json/wp/v2/
) only gets cached/hits a cache when it’s sent directly from the browser’s address bar, whether logged in or not. When the same request is made indirectly as a result of loading a backend page, the plugin always gets bypassed.
Is this the intended behaviour?
]]>I would like to report a significant issue with the performance of the plugin on my website. Since activating the plugin, I’ve noticed a substantial increase in server load, with excessive resource consumption every time a user accesses the application. It seems that the plugin is consuming a large amount of memory and processing power, leading to a noticeable slowdown in site performance.
Although I had hoped the plugin would enhance the site’s performance and reduce server load, I am experiencing the opposite, as the strain has become unmanageable, directly affecting the user experience.
I hope you can provide a solution or recommendation to alleviate this burden and improve the efficiency of the plugin. Thank you for your attention, and I look forward to your prompt response.
Best regards,
]]>WP Rest Cache nicely caches JSON requests like this:
/wp-json/wp/v2/post_type?_embed=&page=1&per_page=80
However, when I update a post of the post_type above, this cache is not flushed.
That is not ideal.
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, false given in /var/www/public/wp-content/plugins/wp-rest-cache/admin/class-admin.php:363 Stack trace: #0 /var/www/public/wp-content/plugins/wp-rest-cache/admin/class-admin.php(363): count() #1 /var/www/public/wp-includes/class-wp-hook.php(324): WP_Rest_Cache_Plugin\Admin\Admin->display_notices() #2 /var/www/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #3 /var/www/public/wp-includes/plugin.php(517): WP_Hook->do_action() #4 /var/www/public/wp-admin/admin-header.php(303): do_action() #5 /var/www/public/wp-admin/index.php(137): require_once('...') #6 {main} thrown in?/var/www/public/wp-content/plugins/wp-rest-cache/admin/class-admin.php?on line?363
PHP Version: 8.3.1
]]>Hello,
Thank you for this wonderful plugin.
I use Redis object cache on my WP sites — should I enable WP REST Cache’s Memcache(d) option?
Thank you,
-ac
Hello,
we are using WP Rest Cache plugin to cache our REST API responses and they’re getting cached okay. But if we enable the cron that regenerates caches, the URL’s that are being called are wrong (so we get 404’s).
If i check in the database, it looks okay (request_uri), and also if i do the var_dump to regenerate_expired_caches function, the $result[‘request_uri’] looks fine. Same thing if i manually run the cron with wp-cli.
But when the URL is called from WordPress, we see 404 in our nginx logs. It usually looks something like:
domain.com/en//en/wp-json/wp/v2/properties?something=something – this makes a redirect to
domain.com/en/en/wp-json/wp/v2/properties?something=something which is a 404. Correct URL would be domain.com/en/wp-json/wp/v2/properties?something=somethings, so i think that we get a double WPML language code somewhere.
Have anyone had any experience with this behavior?
Thanks.
Hello,
When trying to use the CLI to attempt to flush a post type specific cache, e.g.
wp wp-rest-cache flush post
I get the error:
Too many positional arguments: post
Running wp wp-rest-cache flush
seems to work OK…
I change the default Rest API prefix from ‘wp-json’ to ‘api’ using this filter in a mu-plugin.
<?php
function wpr_rest_api_prefix ()
{
return 'api';
}
add_filter( 'rest_url_prefix', 'wpr_rest_api_prefix');
And I think this plugin does not detect this. Because nothing is listed in ‘Endpoint API caches’.
If I’m right, can you add this feature, please? Thanks in advance.
]]>Hi,
As the developer of the?Easy Form Builder plugin, I’m seeking some advice about potential conflicts with WP REST Cache.
Here is the function I am currently using for internal caching:
public function get_efbFunction($state) { if (isset($this->efbFunction)) return $this->efbFunction; $efbFunctionInstance; if (false === ($efbFunctionInstance = wp_cache_get('efbFunctionInstance', 'emsfb'))) { if (!class_exists('Emsfb\efbFunction')) { require_once(EMSFB_PLUGIN_DIRECTORY . 'includes/functions.php'); } $efbFunctionInstance = new \Emsfb\efbFunction(); wp_cache_set('efbFunctionInstance', $efbFunctionInstance, 'emsfb', 3600); // 1 hour cache } $this->efbFunction = $efbFunctionInstance; if ($state == 1) return $this->efbFunction;}
My concern is whether using?wp_cache_get
?and?wp_cache_set
?for internal caching might cause any conflicts with WP REST Cache. Has anyone had similar experiences or know of best practices to ensure they work together smoothly?
Any guidance or insights would be greatly appreciated.
Thank you for your help!
Best regards,
]]>Hello, I have the following endpoint: ‘products’ in the namespace: ‘wc/v3/ext’
I am using the following to register the route and enable caching.
I can access the endpoint successfully; I can confirm through debugging that the namespace and endpoint are added to the allowed endpoints.
The plugin is activated.
I have yet to be able to cache a response.
public static function RegisterRoute( string $namespace, string $endpoint, array $methods, object $handler, bool $enableCache = false ) {
add_action('rest_api_init', function () use ($namespace, $endpoint, $methods, $handler) {
register_rest_route($namespace, '/' . $endpoint, array(
'methods' => $methods,
'callback' => array($handler, 'wcre_endpoint_callback')
));
});
if( $enableCache ) {
add_filter( 'wp_rest_cache/allowed_endpoints', function ($allowed_endpoints) use ($namespace, $endpoint) {
if ( ! isset ( $allowed_endpoints[ $namespace ] ) || ! in_array( $endpoint, $allowed_endpoints[ $namespace ] ) ) {
$allowed_endpoints[ $namespace ][] = $endpoint;
}
return $allowed_endpoints;
}, 10, 1 );
}
}
]]>
I am hoping this plugin will work for the “/wp-json/wp/v2/users?search=” request URI which is being called from a third-party service used to sync users between that service and our WordPress site.
The plugin is set up with the default settings.
I see the plugin did create an endpoint API cache for “/wp-json/wp/v2/users?search=” and the “# Cache Hits” column is increasing over time.
However, I am not quite sure why Expiration is always “Flushed” and Active is always a red X.
Is this correct behavior? Is there something additional I need to do? Or is it working as expected?
Thank you.
]]>Dear all!
function wprc_add_imserv_compositor_endpoint( $allowed_endpoints ) {
if ( ! isset( $allowed_endpoints[ 'wp/v2' ] ) || ! in_array( 'compositor_rest_api', $allowed_endpoints[ 'wp/v2' ] ) ) {
$allowed_endpoints[ 'wp/v2' ][] = 'compositor_rest_api';
}
return $allowed_endpoints;
}
add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_imserv_compositor_endpoint', 10, 1);
This code doesn’t work for us. Rest requests are not caching.
Using basic settings after installation. Wp native rest api requests caching works.
Is it possible to set a specific Cache timeout for a certain endpoint?
Like Category / Tags, example I’d like tags to set for 15 mins. then the rest of the endpoints to like 1 yearm is that possible?
Thanks!
]]>This may be off-topic or a noob question, so I apologise in advance, but would really appreciate some help here.
I noticed that 2 days after I installed the plugin, the core web vitals report in GSC started showing issues with LCP in half of my article pages. Then a few days after that, traffic started dropping.
I understand that CWV are not a ‘big’ ranking factor so that might not be causing the drop in traffic, but keen to get some thoughts on this. Thank you! ??
]]>Although the WooCommerce REST API is not caching responses, the WP REST API is successfully implementing caching.
Thank you.
]]>I allow users to update a particular custom post type in the frontend.
It appears that, when this happens, the cache for the post in question is not automatically cleared.
How do I get the cache to clear for one specific post? I can do this in the backend, but I want to trigger this automatically, or trigger this via a function call.
Can this be done?
]]>hi
first of all , thank you for the plugin
i have problem when i change cache setting to
time out = 5 min , regenerate = 5 min
the wordpress going down and not showing anything and i should restart my server and set config to old version
please help me on this issue
]]>How to cache this endpoint /wp-json/uap/v2/uoa_redirect/ it doesn’t appear on endpoint api cache tab?
]]>Getting this error a lot so I have had to disable plugin..
PHP Warning: Undefined array key “REQUEST_METHOD” in /wp-content/plugins/wp-rest-cache/includes/api/class-endpoint-api.php
Hi everyone, I’m facing an error.
With WP Rest Cache plugin activated, after the last update, if I try to delete an element, like a page, then go to trash bin and try to delete it permanently, WordPress returns “No naughty business please”.
If I deactive the plugin and then try to redo this action, then I can delete it permanently.
Is someone facing the same issues?
Thanks for the help!
]]>Hello,
I have noticed that there is a php warning when the plugin tries to generate a new cache key. It should be a simple fix.
In function get_cache you should check if $exparation is set (line: 134).
Warning (PHP 8.1):
Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in /srv/www/hit2023/current/web/app/plugins/wp-rest-cache/includes/caching/class-caching.php on line?135
I have a custom endpoint that delivers different results based on user authorizations. Obviously all users use the same endpoint, though. (In my case: phototastisch/v1/albums
) and SHOULD NOT get the same cached result.
I see that theres a cache key in “Endpoint API Caches” – surely theres a way to realize what I’m looking for.
Or is this considered bad practice? Even if I only have 10-20 users?
Thanks for your help!
]]>Hey! Sorry for the noob question; It’s been a long time since I’ve worked with PHP and was never really that good with it (I’m more a Front-End guy)
I’m using a plugin that syncs my Lightroom galleries to WordPress (WP/LR, really nice) – and whenever WP/LR updates a collection inside of WordPress, I would like to flush (or delete?!) my handwritten custom endpoint for that collection.
add_action('wplr_update_collectiongallery', function($collectionId, $collection) {
// ... preparing stuff to update a post
// Update the post into the database
wp_update_post($post_data);
// flush WP REST cache
if (function_exists('delete_cache_by_endpoint')) {
delete_cache_by_endpoint('phototastisch/v1/albums'); // path will obviously come from a parameter
}
}, 10, 2);
As of right now this is not flushing/deleting anything. I don’t know how to debug this properly; my guess is that the if function_exists
is falsy and that delete_cache_by_endpoint
does not exist in my custom plugin file /wp-plugins/phototastisch/phototastisch.php
Can you tell me how I can flush/delete (whats the difference anyways?) in this action?
Thanks a lot!
]]>Hello. I have a custom post type called downloads
that I have created a custom REST controller for. I have registered the endpoints with the wp_rest_cache/allowed_endpoints
filter. The caching is working. I need to clear that cache whenever a downloads
post is updated though. If my downloads related endpoints are all grouped under vc/v1/downloads
, how would I programmatically clear everything under vc/v1/downloads
when a download is updated?
Inspecting the headers of the cached API responses, it appears that the browser cache duration is set to 48 hours (172800 seconds).
Is there a way to change this?
]]>I’m using backbone to access the REST API. Requests made using backbone do not show up in the list of cached REST requests. Is this because backbone always adds a nonce?
If so, how to circumvent this?
]]>Hello, should this plugin be network activated?
]]>