Varnish Purging

I am using W3TC to assist in purging my Varnish Cache on a separate server when ever a post or page is updated- this works fine. However, when using BeavBuilder to edit or make a page, publishing the page does not seem to purge Varnish, and I’m guessing that W3TC Varnish purging is not triggering when BeavBuilder saves pages.

For a multisite that would have people editing their subsite with the page builder and wondering why the page never changes after they save, this is a very bad thing.
How do I fix this?

Thanks!

Hey Carmelo,

Can you tell me what W3TC settings you are using to do this? Also, we’re using wp_update_post to save builder data which is the same function WP uses, so maybe they’re not hooking into the save correctly. If not, you could always look at doing it yourself using the wp_insert_post action.

Justin

I’m not doing anything special, just enabled Varnish Cache purging under the Reverse proxy setting, and pointed it to my separate cache server- I verified this works fine under normal wordpress usage, but just doesn’t want to purge when BeaverBuilder saves pages.

I will be able to check my ‘Page Cache Settings’ on Wednesday as I am away from my sites at the moment. I believe they are all mostly default settings, but i’ll let you know if any settings in there make BeaverBuilder purge the cache.

You mention about wp_insert_post. How can I use wp_insert_post to assist in purging the cache?

-Carmelo

Thanks, Carmelo. Let me know about those settings when you can. Actually, can you export them? I want to try and find out how W3TC is purging the varnish cache.

You mention about wp_insert_post. How can I use wp_insert_post to assist in purging the cache?

You could write a function that purges it. I’m not sure what the function would look like, but the general idea is…

function my_purge_varnish() {
// Purge logic here…
}

add_action( ‘wp_insert_post’, ‘my_purge_varnish’ );

Thank you very much for your reply.

So after some more testing, here are my observations on my particular system:

  • I do have a SSL encrypted Backend, but the issue doesn’t appear to be related.
  • My varnish purge policy settings (Page Cache Settings): FrontPage-PostPage-PostsPage-BlogFeed are checked, rss (default) is checked, purge limit of 10, and purge sitemaps set at ([a-z0-9_-]?)sitemap([a-z0-9_-])?.xml
  • The admin user on a subsite who is building a page with beaverbuilder publishes that built page, the next page showing up after publishing does NOT show the updated page, and it looks like nothing has changed after publishing.
  • Any regular visitor that isn’t logged into the backend (or not logged into the backend on that same subsite) WILL see the new updated page so cache purging seems to actually purge.
  • I traced this down to the ‘?’ appended to the end of the address of the homepage that was just edited. So, for example, after I’m done editing the subsite homepage https://subsite.mainsite.com, after pushing BeaverBuilder’s publish button, it redirects to https://subsite.mainsite.com/? and for some reason this page stays cached, always showing an older version.
  • Though I only tested it on one other page, pages that aren’t subsite homepages don’t seem to be affected, regardless of whether there is a ? appended to the end of the address or not. For example, https://subsite.mainsite.com/contact-us/? seems to show the page updated just fine after pushing publish. Weird?
  • I made a fix for it with varnish in the default.vcl, telling it to pass/not-cache any url that has ‘?’ at the very end of the url. Something like: if (req.url ~ “?$”) { return (pass); }
  • This is intended as a temporary fix, though I can see it as a permanent fix, as long as I don’t encounter any ‘?’ at the end of urls except for beaver builder doing it.

Is this something you guys can consider looking into taking out? Or is the ‘?’ necessary? Another fix could be having an option that allows the network admin to choose the action after the publish button: show the page like it does, or don’t show the page and go back to the pages listing.

How do I upload my exported w3tc settings onto this forum by the way. I don’t see an obvious way to do it…

Thanks!

Hey Carmelo,

Thanks for the detailed follow up!

Is this something you guys can consider looking into taking out? Or is the ‘?’ necessary?

Definitely, I don’t think we need it at all once the page is published. I’ve made a note to look into getting that done for the next release.

How do I upload my exported w3tc settings onto this forum by the way. I don’t see an obvious way to do it…

No need to, I think we know what the issue is now :slight_smile:

Justin