0

How can I set WordPress to delete transients when a post or a page has been updated or published?

1 Answer 1

2

The technical side of it depends on the storage used.

  1. For default database storage the transient entries can be queried and deleted, since they have specific naming format.
  2. For enabled Object Cache storage cache can be flushed, which will get got cache and transient.

The practical side of it — this is Bad Idea.

Transients store a lot of things that are not meant to be flushed too often, such as plugin/theme update data. Flushing that will cause WP core to immediately try to query it again, grinding page load to a halt.

I remember the time one of major plugins had actually shipped cache flush on post save. The effect on performance was disastrous, not to mention what–were–they–thinking reactions.

In a nutshell — if you think regular eager cache flushing is solving something for you then your actual problem is likely problematic approach to caching, which needs refinement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.