I am trying from console to purge and refresh one specific link of my magento 2 store in Varnish. I don't want to clear the whole cache but just one link.

I tried:

curl -X PURGE http://www.example.com/my/link


curl -X PURGE https://www.example.com/my/link

but don't work.

Result of curl is:

<!DOCTYPE html>
    <title>400 X-Magento-Tags-Pattern or X-Pool header required</title>
    <h1>Error 400 X-Magento-Tags-Pattern or X-Pool header required</h1>
    <p>X-Magento-Tags-Pattern or X-Pool header required</p>
    <h3>Guru Meditation:</h3>
    <p>XID: 3000241</p>
    <p>Varnish cache server</p>

Then I tried with varnishadm

varnishadm -T -S /etc/varnish/secret ban "req.http.host == example.com && req.url == /my/link"

This seems working but I am not sure. I used "ban" there and I don't know if with this I excluded this link from Varnish?

I use Magento 2 default.vcl, Varnish 6 and Nginx. I saw that Magento's vcl has this section for purging:

acl purge {
sub vcl_recv {
    if (req.method == "PURGE") {
    # check if the client is allowed to purge content
        if (client.ip !~ purge) {
            return (synth(405, "Method not allowed"));
        # To use the X-Pool header for purging varnish during automated deployments, make sure the X-Pool header
        # has been added to the response in your backend server config. This is used, for example, by the
        # capistrano-magento2 gem for purging old content from varnish during it's deploy routine.
        if (!req.http.X-Magento-Tags-Pattern && !req.http.X-Pool) {
            return (synth(400, "X-Magento-Tags-Pattern or X-Pool header required"));
        if (req.http.X-Magento-Tags-Pattern) {
          ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
        if (req.http.X-Pool) {
          ban("obj.http.X-Pool ~ " + req.http.X-Pool);
        return (synth(200, "Purged"));

As I understand this section with the appropriate insert in


it permits to clean Varnish from magento admin which for me it works.

But why with

curl -X purge

can't clear one link?

What I do wrong? Can somebody explain please all these?

1 Answer 1


The result of your curl command would help? If empty try adding -I.

Solution from the comments:

Add any or both of the mentioned headers in your curl.

curl -X PURGE -H 'X-Magento-Tags-Pattern: .*' https://www.example.com/my/link

You can find what magento sets by eg. varnishlog | grep -i tags

  • You are right....I forgot it....Editing now
    – G. G.
    Commented Feb 6, 2020 at 23:43
  • 1
    Well I guess you need to add one or both of those headers in your curl then. eg. curl -X PURGE -H 'X-Magento-Tags-Pattern: .*' https://www.example.com/my/link You can find what magento sets by eg. varnishlog | grep -i tags
    – apeters
    Commented Feb 7, 2020 at 1:15
  • Ok...Checking that!
    – G. G.
    Commented Feb 7, 2020 at 10:11
  • Worked my friend....Please add it in your answer
    – G. G.
    Commented Feb 7, 2020 at 19:11
  • I did... glad to help.
    – apeters
    Commented Feb 9, 2020 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.