Forum Replies Created

Viewing 15 replies - 76 through 90 (of 99 total)
  • Plugin Author Acato

    (@acato)

    Hi @jenilk

    I just did a really quick test on a local development environment to see if everthing would still be working when W3 Total Cache is activated. (Since W3TC is a very advanced plugin with a lot of possible settings, a quick test is never enough to really be sure.)

    Since we use transients to store the caches, I specifically targetted my test to Object caching. I installed Memcached on my local environment, activated Object caching in W3TC and set it to use Memcached. Everything kept on working as it should πŸ™‚
    However, when I unchecked the setting ‘Store transients in database’ the caching of the REST API broke. At this point I have no idea why, it could be simply that I misconfigured Memcached on my local environment, or it could have some deeper cause. Nevertheless, it is something that we have to dive deeper into in order for us to be able to actually tell what is causing it and if and how we can solve it.

    So for now: you can use W3 Total Cache together with our WP REST Cache plugin, as long as you do not uncket the setting ‘Store transients in database’. We will however investigate this further and if possible solve the issues with this setting.

    Plugin Author Acato

    (@acato)

    Hi @adamhammad

    We have just released a new verion of the plugin. We have added a GET-parameter you can use to skip caching. Simply add ?skip_cache=1 to you REST call.

    Please let us know if this works for you!

    Plugin Author Acato

    (@acato)

    Hi @skarbona

    Thank you for your kind review!
    Please let us know if we can be of any assistance, if you are missing functionalities or if you have any suggestions.

    Plugin Author Acato

    (@acato)

    Hi @adamhammad

    Well creating a new (duplicate) endpoint doesn’t feel right.

    After some consideration I think there are two possible solutions to this problem:

    1. We add a check to see if the current user is authenticated and if so, do not use caching. But that would mean that all responses for authenticated users are no longer using caching. That doesn’t feel right either.

    2. We can implement the option for you to use an extra parameter to tell the WP REST Cache plugin to skip caching. That way you can decide for each request if you want to use caching or not. So for admin users you would add an extra parameter to the REST call. Does that sound like an option to you?

    Forum: Reviews
    In reply to: [WP REST Cache] Works great
    Plugin Author Acato

    (@acato)

    Hi @imranp

    Thank you for your review!
    Please let us know if we can be of any more assistance.

    Forum: Reviews
    In reply to: [WP REST Cache] Excelent
    Plugin Author Acato

    (@acato)

    Hi @djcelo

    Thank you for your review!
    Please let us know if we can be of any assistance, if you are missing functionalities or if you have any suggestions.

    Plugin Author Acato

    (@acato)

    Hi @waldub

    We just released a new version of our plugin which should solve this error.

    Plugin Author Acato

    (@acato)

    Hi @waldub

    Thank you for using our plugin!

    We just released a new version which should solve at least part of your problem (the fact the error doesn’t go away after you deleted your code).

    I am however not sure why you ever got this error, at some point your filter function must have returned a string in stead of the array $allowed_endpoints. Could you please download the latest version of our plugin and retry?

    Plugin Author Acato

    (@acato)

    About your endpoint that checks authentication inside them: are you sure you actually want this endpoint to be cached?

    At this point I don’t really see an option to do this, the code where we check if we should cache or not (\includes\api\class-endpoint-api.php line 203) is executed from a must use plugin and therefore is executed before any plugin or theme code. So adding a filter there will not help you very much since the apply_filters is than executed before you added your filter.
    I am going to think about a solution for this and discuss it internally, maybe we can find a solution that works for you.

    Plugin Author Acato

    (@acato)

    Hi @adamhammad

    We just released a new version of our plugin which now includes a function to programatically flush caches by endpoint. So for instance if you want to flush the caches for the endpoint /wp-json/wp/v2/pages you can do so like this:
    \WP_Rest_Cache_Plugin\Includes\Caching\Caching::get_instance()->delete_cache_by_endpoint( '/wp-json/wp/v2/pages' );

    This function accepts two extra parameters:
    1. $strictness: This defines how strict you want the caches to match, you have three options for this:
    \WP_Rest_Cache_Plugin\Includes\Caching\Caching::FLUSH_STRICT: Delete caches by an endpoint path matching only this exact same endpoint path (and query params).
    \WP_Rest_Cache_Plugin\Includes\Caching\Caching::FLUSH_PARAMS: Delete caches by an endpoint path matching the exact same endpoint path with any query params that might have been used.
    \WP_Rest_Cache_Plugin\Includes\Caching\Caching::FLUSH_LOOSE: Delete caches by an endpoint path matching any cache that was called starting with the endpoint path (ignoring any query params or subpaths following the given path).

    2. $force: Should the caches be deleted ($force = true) or just flushed ($force = false).

    Plugin Author Acato

    (@acato)

    Hi @adamhammad

    We just released a new version of our plugin which should fix the error you got.

    Plugin Author Acato

    (@acato)

    Hi @rorymheaney

    Thank you for your really nice review!
    Please let us know if we can be of any assistance, if you are missing functionalities or if you have any suggestions!

    Plugin Author Acato

    (@acato)

    Hi @adamhammad

    I will add it to my todo-list. Unfortunately I don’t have any time left to work on it this week.

    Plugin Author Acato

    (@acato)

    The Item API Caches are caches of a single item from a multi-item endpoint. So for instance the /wp-json/wp-/v2/posts contains multiple posts. Now let’s say this endpoint contains the posts with the id’s 1, 2, 3, 4 and 5. Whenever one of these posts is update the endpoint cache for the posts is flushed.
    The item caches are caches of the separate posts within that endpoint. This is done so that when for instance the post with id=2 is edited, the posts endpoint is flushed and the item cache for id=2 is also flushed. Now when the posts endpoint is requested again, the posts 1, 3, 4 and 5 are retrieved from the item cache and post 2 is regenerated.

    This technique however only works for endpoints that use the WP_REST_Posts_Controller, the WP_REST_Terms_Controller or the WP_REST_Attachments_Controller from the WordPress Core. It doesn’t work for custom endpoints (even not when they extend one of those controllers), because in order for this to work we extend those controllers.

    Plugin Author Acato

    (@acato)

    Hi @adamhammad

    At this point there are only two functions available for programatically flushing caches:

    1. Flush all caches of a specific object type
    Example:
    \WP_Rest_Cache_Plugin\Includes\Caching\Caching::get_instance()->delete_object_type_caches( 'products' );
    This deletes all caches for object type products

    2. Flush a specific cache
    Example:
    \WP_Rest_Cache_Plugin\Includes\Caching\Caching::get_instance()->delete_cache( '8dbc9f7badb0ed2d50f1eaf200422a49' );
    Unfortunately as you can see, you would need the cache key for that. Which by the way is simply a md5 hash of the endpoint path with query parameters. So for https://www.domain.com/wp-json/wp/v2/pages the cache key would be md5( '/wp-json/wp/v2/pages' );. However keep in mind that any query parameters should be ksort’ed.

    Your question makes me however realize that we should add more (better usable) functions for flushing caches programatically. I will discuss this internally and add some functions in the near future.
    Do you have any suggestions on how you would like to do this? I.e. flushing all caches for a specific endpoint regardless of the query parameters, flushing a cache by it’s specific path (without the need to hash it yourself), … ?

Viewing 15 replies - 76 through 90 (of 99 total)