Varnish and IPB
nfn at sapo.pt
nfn at sapo.pt
Sun Aug 19 12:17:26 CEST 2012
Hello,
I'm trying for some days to setup varnish with IPB (Invision Power
Board) without success.
The relevant information is:
Cookie member_id: can have -1 (log out users); 0 (guests) and > 0 (members)
Cookies guestSkinChoice|language|mobileBrowser; don't want to cache
when they are present.
Cookie session_id: php session id; Must be removed
So, in general, I can only cache when member_id is (0|-1) and no other
cookies are present.
By default, varnish should not cache anything ... I just want to cache
url's started by:
"/"
""index.php"
"/topic"
"/forum"
Here is a vcl that is not working as expected and I don't know what is
wrong. I using varnish 3.
Can someone give me some help?
Thanks
----------------------------------------------
sub vcl_recv {
if (req.http.Cookie) {
set req.http.Cookie = ";" + req.http.Cookie;
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
set req.http.Cookie = regsuball(req.http.Cookie,
";(member_id|guestSkinChoice|language|mobileBrowser)=", "; \1=");
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
if (req.http.Cookie == "") {
remove req.http.Cookie;
}
}
if ((req.http.Cookie ~ "member_id=" && req.http.Cookie !~
"member_id=(0|-1)") ||
req.http.Cookie ~ "guestSkinChoice" ||
req.http.Cookie ~ "language" ||
req.http.Cookie ~ "mobileBrowser")
{
return(pass);
}
}
sub vcl_fetch {
if (beresp.http.set-cookie) {
set beresp.http.set-cookie = ";" + beresp.http.set-cookie;
set beresp.http.set-cookie = regsuball(beresp.http.set-cookie, ";
+", ";");
set beresp.http.set-cookie = regsuball(beresp.http.set-cookie,
";(member_id|guestSkinChoice|language|mobileBrowser)=", "; \1=");
set beresp.http.set-cookie = regsuball(beresp.http.set-cookie,
";[^ ][^;]*", "");
set beresp.http.set-cookie = regsuball(beresp.http.set-cookie,
"^[; ]+|[; ]+$", "");
if (beresp.http.set-cookie == "") {
remove beresp.http.set-cookie;
}
}
if ((beresp.http.set-cookie ~ "member_id=" &&
beresp.http.set-cookie !~ "member_id=(0|-1)") ||
beresp.http.set-cookie ~ "guestSkinChoice" ||
beresp.http.set-cookie ~ "language" ||
beresp.http.set-cookie ~ "mobileBrowser")
{
set beresp.ttl = 0s;
} else {
set beresp.ttl = 120s;
}
## == Index ==
if ((req.url == "/" || req.url == "/index.php") && beresp.ttl > 0s)
{
unset beresp.http.set-cookie;
set beresp.ttl = 10m;
}
## == Topic ==
if ((req.url ~ "^/topic/") && beresp.ttl > 0s)
{
unset beresp.http.set-cookie;
set beresp.ttl = 30m;
}
## == Forum ==
if ((req.url ~ "^/forum/") && beresp.ttl > 0s)
{
unset beresp.http.set-cookie;
set beresp.ttl = 60m;
}
}
More information about the varnish-misc
mailing list