purge content after POST request

Tobias Eichelbrönner tobias.eichelbroenner at lamp-solutions.de
Thu May 10 21:54:15 CEST 2012


Hi,

on a webpage behind varnish, visitors can leave comments.
New comments are sent to the server via htmlform using POST.

The Problem is, that new comments are not visible until I clear the cache.

I tried to purge or ban some content from cache, after a post request is
sent. For example like this:

sub vcl_recv {
    if (req.request == "POST") {
        ban("req.http.host == " + req.http.host + "&& req.url == " +
req.url);
        return (pass);
    }
}

or this:

 sub vcl_fetch {
    if (req.request == "POST") {
        ban("req.http.host == " + req.http.host + "&& req.url == " +
req.url);
        set beresp.ttl = 0h;
    }
}

or even this:
sub vcl_hit {
    if (req.request == "POST") {
        purge;
    }
    return (deliver);
}

Does anyone solved a problem similar to mine?

Sincerly,

Tobias



More information about the varnish-misc mailing list