Cache invalidation is hard, proven times and times by the “clear cache” and “delete all caches” buttons in various caching plugins and hosting control panels.
While some of the concepts in this post are applicable to various types of caching, I’ll stick to page caching for simplicity, and of course WordPress.
I’m not going to go into much detail here. I’ve done a live stream a few months ago where I wrote a page caching plugin from scratch for WordPress. If you’re interested in the nuts and bolts, go check that out. Otherwise, here’s a very simple version of what happens in WordPress’ advanced-cache.php, which loads very very early.