Varnish doesnt PURGE urls

hamidreza hosseini hrhosseini at hotmail.com
Tue Dec 10 14:33:28 UTC 2019


Hi,

I've two varnish, that one of them use ram as backend and another file as backend, requests first come to varnish(ram) and then go to another server in varnish(file) and then go to nginx, this is my diagram:


Req=====> [varnish ram (varnish fronted)] =======> [varnish file (varnish backend)] =====> [Nginx]

And following file is my vcl configuration file that i'm using,
when i  purge a url there is  no problem with frontend but it doesnt purge from backend
I run varnishlog on both servers and i determines diffrences in link below:
https://www.diffchecker.com/NRPsTEGO
(Note that my problem is with varnish backend it doesnt purge the url, one of the wierd things is that logs show that the url purged successfully and returned 200 ok , but that url doesnt remove from cach )
How can i solve my problem?

vcl config file:

### Naming note: use [0-9a-zA-Z_] only. no -. Or use camelCase ;-)
vcl 4.0;

import directors;


backend varnish_malloc_01 { .host = "192.168.200.12"; .port = "8080"; }


sub vcl_init {
    new varnish_cluster = directors.round_robin();
    varnish_cluster.add_backend(varnish_malloc_01);

}


acl purge {
    "localhost";
    "192.168.200.0"/24;
;
}


sub vcl_recv {

sub vcl_recv {
    #set req.backend_hint = varnish_cluster.backend();
    unset req.http.Cookie;
    if (req.method == "PURGE") {
        ### TODO: also purge from the backend
        if (!client.ip ~ purge) {
            return(synth(405,"Not allowed."));
        }
        return (purge);
    }
}

sub vcl_backend_response {
    set beresp.ttl=48h;
    # Don't cache 404 responses
    if ( beresp.status == 404 ) {
        set beresp.ttl = 120s;
        set beresp.uncacheable = true;
        return (deliver);
    }
}

 Best regards

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20191210/659ab3e7/attachment.html>


More information about the varnish-misc mailing list