Hello,
I'm running a forum that has a ttl to expire content to guests only, but I
would like to opitmize it to purge a page when we have new posts or after 24h
(to update counters).
My 1st question is how can I get the hiden input value I have that tell
varnish that we have a new post?
<input type="hidden" name="canpurge" value="/topic/123-my-topic/" />
I was thinking of something like this:
sub vcl_recv {
if (req.request == "POST" && FORM.FIELD == "canpurge) {
purge req.http.host == example.com && req.url ~ ^FORM.CANPURGE.VALUE.*$
}
}
This is an excertt of my actual configuration:
====================================================================================================
sub vcl_recv {
## == Mobile ==
if (req.http.User-Agent ~
"(iPad|iPhone|iPod|Android|SymbianOS|^BlackBerry|^SonyEricsson|^Nokia|^SAMSUNG|^LG)")
{
return(pass);
}
if (!((req.http.Cookie ~ "member_id=" && req.http.Cookie !~
"member_id=(0|-1)") || req.http.Cookie ~ "(guestSkinChoice|language)")) {
if (req.url ~ "^/(public|forum|topic|gallery|blogs|members|user|calendar)/") {
unset req.http.cookie;
set req.grace = 15s;
}
if (req.url == "/" || req.url == "/index.php") {
unset req.http.cookie;
set req.grace = 15s;
}
}
}
sub vcl_fetch {
if (!((req.http.Cookie ~ "member_id=" && req.http.Cookie !~
"member_id=(0|-1)") || req.http.Cookie ~ "(guestSkinChoice|language)")) {
## == INDEX ==
if (req.url == "/" || req.url == "/index.php") {
unset beresp.http.set-cookie;
set beresp.ttl = 300s;
set beresp.grace = 30s;
}
## == ESI ==
if (req.url ~ "^/(gallery/image|topic)/") {
set beresp.do_esi = true;
unset beresp.http.set-cookie;
set beresp.ttl = 300s;
set beresp.grace = 30s;
## Others
} elseif (req.url ~ "^/(public|forum|gallery|blogs|members|user|calendar)/") {
unset beresp.http.set-cookie;
set beresp.ttl = 600s;
set beresp.grace = 30s;
}
}
}
====================================================================================================
Thanks
_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc