Closed davelit closed 3 years ago
Clearing the cache after a scheduled post has been published was taken into account when creating the cache clearing handling. I just did a quick test on a scheduled post to check this behavior. The save_post
hook was fired as expected and the post status was publish
. This called Cache_Enabler::clear_cache_on_post_save()
, which then called Cache_Enabler::clear_associated_cache()
. Are you replicating a different behavior?
We actually used to use the transition_post_status
hook from version 1.5.0 to 1.6.2 but this was removed in PR #216 in favor of the new handling.
Thank you for looking into this. I just noticed that my post type archive page would only refresh after clicking the Clear Page Cache button in the admin bar, and maybe jumped a bit early to conslusions. It's well possible that something in my custom setup is the actual culprit. I'll investigate a bit further and will update or close this issue when I know more.
I was wrong, please accept my apologies for jumping to conclusions. The caches get cleared just fine when scheduled posts get published.
In case you are interested, the root cause on my end is that another plugin that I'm using (Polylang) is delivering a bad archive link when get_post_type_archive_link() is called through the 'publish_future_post' event ( $this->curlang is still nulll in PLL_Filters_Links->post_type_archive_link()). I will try to raise the issue with the Polylang team instead.
Related issue: polylang/polylang#828.
Thank you again for Cache Enabler!
I noticed that the associated caches only get cleared when a post is saved or trashed. However, posts can also be scheduled for publishing at a future date, triggering updates to associated post type, author and taxonomy pages.
I think you could use the same approach you used for comments and latch onto the
transition_post_status
hook and callCache_Enabler::clear_associated_cache()
when it fires.