How can I set WordPress to delete transients when a post or a page has been updated or published?
1 Answer
The technical side of it depends on the storage used.
- For default database storage the transient entries can be queried and deleted, since they have specific naming format.
- 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.