Support » Plugin: WP REST Cache » Delete All Cache Entries?

  • Resolved workforpizza

    (@workforpizza)


    Hello there,

    we’re using this plugin as a working solution to cache large API endpoints delivered into a mobile app. Since we have a lot of users with custom endpoints/params, we collect a lot of cached endpoint entries which get invalidated when a post is updated. But even in the “invalidated” state they clutter the database and I wondered if there is a way to quickly delete >70.000 entries without having to bulk delete them in groups of 500?

    If I delete the entries in the wp_wrc_caches-Table is that enough?
    Thanks for a quick reply and have a nice day.

    Flo,

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @workforpizza

    There are two options to delete them all:

    1. You can have them deleted programmatically, by using the delete_cache_by_endpoint(...) function (see our post in this topic, for more details on how to use it). If you set the third parameter to true it will delete all records. However do keep in mind that running that function will not delete them instantly, but it will trigger a cron job 5 minutes from now to delete them (this is for performance reasons).

    2. Yes, just like you suggested, you can delete the entries from the wp_wrc_caches table, but do keep in mind the following:
    – You also need to deleted the related entries in the wp_wrc_relations table.
    – Deleting the entries before you flush the caches will result in orphan-transients. The plugin will not be able to delete the transients anymore. However, these transients will not be used anymore, so they will expire eventually.

    Thanks for the quick reply. So this means if I fully clear both wp_wrc_caches and wp_wrc_relations – I should be back to a fresh start? Or are there any entries I shouldn’t delete?

    Plugin Author Richard Korthuis

    (@rockfire)

    Yes if you first click “Clear REST cache” and then fully clear both tables you are indeed back to a fresh start.

    Ok I think that’ll do for now. Just curious: Isn’t there a cronjob that deletes all invalidated cache entries once in a while, or is the cronjob on my site just not working?

    • This reply was modified 2 months, 2 weeks ago by workforpizza. Reason: spelling
    Plugin Author Richard Korthuis

    (@rockfire)

    Hi @workforpizza

    No there isn’t a cron deleting invalidated cache entries, the entries in the wp_wrc_caches table are preserved in order to keep the statistics (nr of cache hits) alive. The cache itself and the relations (in the wp_wrc_relations table) are deleted.

    Since you are asking: can I ask how big your wp_wrc_caches table had become? Maybe we should reconsider deleting more data…

    We’re currently sitting on the wp_wrc_caches at around 24MB, nothing to incredible compared to the wp_post or wp_post_meta. wrc_relactions only at 3,4MB. It just got really impractical, since after saving a post it seems to “check” all 70k+ entries for invalidation. (One of the updates thankfully fixed the long loading on post save, but it still needs a lot of time to clear the caches). Even clicking the “Clear Cache”-Button manually is currently running for about 1,5 hours and displaying 14%.

    I would highly appreciate an option to only store the currently active/valid entries – if someone (like us) doesn’t really need the nr. of hits.

    It’s probably unusual to have such large amounts, so if I can assist with anything else, let me know 🙂

    • This reply was modified 2 months, 2 weeks ago by workforpizza.
    Plugin Author Richard Korthuis

    (@rockfire)

    Wow, you have proven your point 🙂

    I will add it to our todo list, to make it optional to delete inactive entries automatically.

    Thank you very much! 🙏 I will happily report back once it hits live. Time to leave a 5 star rating for this great support!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.