wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
690 stars 216 forks source link

Varnish cache not purged after a scheduled post is published #3689

Open gecon opened 3 years ago

gecon commented 3 years ago

Before submitting an issue please check that you’ve completed the following steps:

Describe the bug Varnish cache is not correctly purged when scheduled posts are published. When a schedule post get's published, the cache for all URLs where this post should appear is not purged (for example homepage should be cleared when a scheduled post is published which should appear in homepage).

To Reproduce Steps to reproduce the behavior:

  1. Create a new post scheduled in 1 hour from now. Make this post to appear also in a category or the homepage, for example have this post to appear on homepage "recent posts".
  2. Make sure your cron is running correctly; The post will be published in 1 hour indeed (and the public URL of the post will work).
  3. The post is published but does not appear on homepage, since the homepage is still cached in Varnish. The publish event for the scheduled post did not purge the cache in order for homepage to get refreshed to have the new post appear.

Expected behavior Pages where the scheduled post appears must be purged from Varnish when a scheduled post gets published (or simply the whole Varnish cache should be purged), in order for the post to show up in all the right pages.

Additional context All other varnish purge commands are working fine on the site. For example editing a post, correctly purges the URL from Varnish.

Backlog Grooming (for WP Media dev team use only)

GeekPress commented 3 years ago

Hi @gecon

Thanks for your contribution.

Just to double-check, can you please confirm you are using our Varnish Add-on?

gecon commented 3 years ago

Hi @GeekPress, yes I am using Varnish addon. Varnish is cleared with success on all other cases (for example when editing a post).

The problem is only when scheduled ("future") posts are getting published by using cron. The future post is published but the pages that reference the new post are not purged from Varnish. I am also using this helper https://github.com/wp-media/wp-rocket-helpers/tree/master/compatibility/wp-rocket-compat-varnish-ip/ which is very simple and must be irrelevant to the problem.

Varnish is purged successfully by WP-Rocket, the problem is when a 'future' post get's published.

GeekPress commented 3 years ago

Ok, thanks for the confirmation :)

gecon commented 1 year ago

Hi, dropping a message after ~ 22 months here. A lot of big news coverage websites are using WordPress nowadays.
Varnish as a caching layer is quite common for such big sites, since they are perfect candidates for Varnish caching to serve most requests without PHP execution.

This bug here makes WP-Rocket a bad idea for those sites. Because more than 90% of the posts are scheduled.

Thank you.