In vcl_hash I have
backend default {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
"localhost";
}
sub vcl_hash {
if(req.http.Cookie ~ "isLogin") {
hash_data("1");
}
}
sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return (lookup);
}
return(lookup);
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 404 "Not in Cache.";
}
}
I use the command below to clear urls. curl -X PURGE http://release.com/user/details
If the URL is cached for registered users, I get below
curl -X PURGE http://release.com/user/details
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>200 Purged.</title>
</head>
<body>
<h1>Error 200 Purged.</h1>
<p>Purged.</p>
<h3>Guru Meditation:</h3>
<p>XID: 1071483546</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>
If it is cached only for registered users, I continue to get below the result. (Although url does "Hits")
curl -X PURGE http://release.com/user/details
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>404 Not in Cache.</title>
</head>
<body>
<h1>Error 404 Not in Cache.</h1>
<p>Not in Cache.</p>
<h3>Guru Meditation:</h3>
<p>XID: 998719206</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>
http://release.com/user/details looks different based on if the user is logged in or not. (i.e. has a cookie isLogin or not). PURGE does not work for URLs that hashed in vcl_hash. It seems to be a mistake or a feature of varnish. Please suggest what can be done.