• Resolved bezbeli

    (@bezbeli)


    Hi, did you ever add hook for when cache is cleared, would be good to have it so it can trigger a url to redeploy site or clear cache ie. for headless or static site. I imagine simplest case would be to fire when Clear REST cache button is clicked.

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

    (@rockfire)

    Hi @bezbeli

    Thank you for using our plugin!

    There are several cases in which a cache record could be cleared, clicking the Clear REST cache button is only one of them:

    • When a users clicks the Clear REST cache button, in this case ALL caches are cleared
    • When a new post/term is added, in this case all overview endpoints of this post type/taxonomy are cleared
    • When a post/term is edited, in this case all caches that have this post/term in it are cleared
    • When a post/term is deleted, in this case all caches that have this post/term in it are cleared
    • When a cache record is expired

    Specifically this last case makes it hard to have a reliable hook for when a cache is cleared. Since we use the transient API, we have no way of detecting if/when a cache record expires. Furthermore, since there are several case in which only a part of the cache records are cleared, how would you want to handle this? Triggering a hook for each seperate cache record isn’t something we are very happy to do, since this would influence performance when adding/editing/deleting a post/term.

    So if you are looking for a hook whenever the Clear REST cache button is clicked, that is something we could add. That is however as said not the only case in which caches are cleared and for the other cases it is a bit harder to have a good hook.

Viewing 1 replies (of 1 total)
  • The topic ‘Hook for when cache is cleared’ is closed to new replies.