Many thanks for those helpful answers, Tim and Erik. It was pretty exciting to get emails
from people so important to the Wikimedia organization.I ended up following Wikia's
approach (it's been tested, after all) and am now seeing a 44%-50% decrease in page
load speeds, as measured by Firebug.
The recommended code for handling requests with authorization credentials or cookies is to
simply pass them to the back-end webserver:
if (req.http.Authorization || req.http.Cookie) {
/* Not cacheable by default */
return (pass);
}
Since Wikia and I both deal with cookies that are used only by the client, we simply unset
the cookies before execution reaches the above code (though I do this only if the
requested URL is in the Mediawiki folder, "/~ptpn/w/"). This is done through the
following VCL code:
if(req.url ~ "ptpn/w/"){
# more typically "^/wiki/"
if(req.http.Cookie ~
"(session|UserID|UserName|Token|LoggedOut)") {
# dont do anything, the user is logged in
} else {
# dont care about any other cookies
unset req.http.Cookie;
}
}
This seems to work quite well and I'm extremely impressed by Varnish's resource
usage.
Once I've had more time to test out and learn my way around the code, I'll try to
update the Mediawiki documentation on Varnish to reflect the above changes and the changes
to VCL since version 3 of Varnish. I may post follow questions then, in particular about
which cookies I need to preserve (I'd like to cut the set down so that I can hit the
cache after I log out, something I can't do now because cookies remain).
Forest
________________________________
From: Erik Moeller <erik(a)wikimedia.org>
To: MediaWiki announcements and site admin list <mediawiki-l(a)lists.wikimedia.org>
Sent: Friday, December 30, 2011 12:15 AM
Subject: Re: [Mediawiki-l] Squid/Varnish and cookies set by Vector and Google Analytics
On Thu, Dec 29, 2011 at 8:49 PM, Tim Starling <tstarling(a)wikimedia.org> wrote:
A VCL routine which parses this header and uses
it to make caching
decisions would solve your problem and, if published, would also be
useful to other sites using Varnish with MediaWiki.
In case it's useful for hacking purposes: It also looks like Wikia's
Varnish config is public and there's a presentation from Artur about
it.
https://svn.wikia-code.com/utils/varnishhtcpd/
http://www.scribd.com/doc/48960012/Varnish-A-State-of-the-Art-High-Performa…
The VCL file doesn't evaluate X-Vary-Options but it simply unsets
cookies for logged out users.
--
Erik Möller
VP of Engineering and Product Development, Wikimedia Foundation
Support Free Knowledge:
http://wikimediafoundation.org/wiki/Donate
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l