• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Varnish Docker - Purging

Patrick Dankers

New Pleskian
Hi all,

Just want to get back on
Varnish HTTP Cache plugin for Wordpress in a Docker container

Which is a great explanation of how to get things setup for use of Varnish though Docker in Plesk and make it work with Wordpress. I have it now working well on mulitple projects (multiple varnish dockers because of various reasons). On both HTTP, HTTPS aswell and also using a variety of other techniques (HTTP/2, combinations of Cloudflare and MAXCDN etc).

But what I am still not able is to make it actually purge without having to restart the docker container.
Is there a clear way of doing this (perhaps even from Wordpress)?

I have tried all the possible plugins but none seem to be able to connect correctly to do so for some reason.
Perhaps I am overlooking something obvious?

Any help would be greatly appreciated.

EDIT:
Perhaps @Viktor Vogel can shed some light on this matter, as he wrote the brilliant article that got me and many others started in the first place.
 
Last edited:
As an update; I am able to get the response using Curl just fine, as in;

Code:
[root@srv pdtemp]# curl -XBAN http://url.extension:port/
<!DOCTYPE html>
<html>
  <head>
    <title>200 Ban added</title>
  </head>
  <body>
    <h1>Error 200 Ban added</h1>
    <p>Ban added</p>
    <h3>Guru Meditation:</h3>
    <p>XID: 48</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>
[root@srv pdtemp]# curl -XBAN http://url.extension:port/
<!DOCTYPE html>
<html>
  <head>
    <title>200 Ban added</title>
  </head>
  <body>
    <h1>Error 200 Ban added</h1>
    <p>Ban added</p>
    <h3>Guru Meditation:</h3>
    <p>XID: 32824</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>
[root@srv pdtemp]#

In which port is the actual port varnish is on in the specific Docker instance.

But the actual Age header of the object does not change.
Perhaps I'm to fresh when it comes to Docker and combining it with Varnish to tell why we DO get that response but not the actual invalidation of the requested object.

If anybody can help me in the right direction that would be wonderful.

If you need addtional information also feel free to ask ;)
 
Ok let me answer some of my own 'stupid' ideas/questions;

- Even though we are using Varnish throught Docker the Purge request can be done just fine on the basic port 80.
Because Varnish is listening on that it will now that a PURGE request will need a specific way of handeling

- After some initial bad testing etc, I noted I could indeed purge through CLI from within the docker container and from the main shell using;
curl -v -H "host: domain.extension" -X PURGE url-to-purge
For quick reference why I first thought this was not working was due to we where running Cloudflare with its optimalization (I could still run the mentioned (be it with a adjustment in the /etc/hosts) but for some reason that does not seems to actually purge the cache (the Age header never gets reset it seems).

- If all else fails restart the Docker container; as it had been a bit of trial and error knowing that this will always make the varnish cache get cleared you can always use it as a last ditch effort.

But back to purging from WP itself, because that it still a thing on itself;

We have showed we can do it from docker container and main cli shell of the server.
So there should not be a real problem in doing it from Wordpress I thought;

1 - Wp-Rocket (our caching plugin of choice) supports Varnish Auto Cache clearing, but does not seem to take for some reason.
2 - Varnish HTTP Purge; notes; We did not find Varnish active for this domain.
3 - Purge Varnish Cache ; notes: The Varnish control terminal is not responding at 127.0.0.1

4 - Varnish Caching .... ok this is suprising a bit; this one actually works (on CRUD actions that is), the purge all does not seem to work.
So I decided to do a little test with Cloudlfare active (as you can still setup the origin ip and the host directly in this plugin)
But then it fails, even tough the ip, hostname etc, should be ok. This needs some more investigating because it would be good to have this working WITH Cloudflare (the optimization bonus it offers itself is nice).

If anybody can share experiences on that that is also appreciated :)
 
Hello Patrick !!
I am unable to purge cache on post update , please tell me how can i make WordPress purge. Can W3 Total Purge ?? Please tell me whcih plugin are you using to purge vrnish in docker. Everything is working fine and i made few changes in vcl file to stop caching feeds and api data but not able to purge articles white editing. I am using Wp Rocket plugin.
 
Hi @Patrick Dankerss
I got everything working like cache and purge with both http and https. But when having Cloudflare proxy orange cloud, purge is not working. I can make it working by edit /etc/hosts and wonder if you have other methods? Thank you.
 
Back
Top