I'm having trouble with a Pressflow install and its lazy session handling.
The issue
Anonymous page views are still getting a session cookie and thus the Cache-Control:max-age header is being set to 0, making it difficult to have Varnish cache pages.
Things to note
I am using the Drupal 5 version of Pressflow (5.21.47) and thus there is no "external cache" setting on the performance tab, but the caching mechanism has been set to Aggressive.
The memcache module D5 patch was applied to PF.
I disabled almost all the modules and this was still a problem. The only remaining modules were: memcache, core - required, ad serving module (with no references to SESSION or COOKIE), jquery update, and maybe one other. At any rate, I tried this with a stock PF5 install with only the memcache module and the Garland theme and had the same issue. It is possible but I don't believe the modules or the theme are at fault.
The varnish config I'm using is based on gchaix's http://blogs.osuosl.org/gchaix/2010/01/23/varnish-config-defaultvcl/
It works, sort of
The problem seems to be that line 790 (or so) in bootstrap.inc requires that there be no session for max-age to be set correctly.
$max_age = variable_get('cache', CACHE_DISABLED) == CACHE_AGGRESSIVE && (!isset($_COOKIE[session_name()]) || isset($hook_boot_headers['vary'])) ? variable_get('cache_lifetime', 0) : 0;
It seemed to me that, since a session cookie was being set for anonymous users, the max-age would never be set correctly. I threw a hack in my bootstrap.inc to see if this was the only issue preventing Varnish from caching pages so I put unset($_COOKIE[session_name()]);
on the line preceding the max age code and low, max age was set correctly. This allowed varnish to begin caching pages. However, I'm sure that I shouldn't have to write a bootstrap hack to get caching to work in PF5 so I would appreciate any advice as to what I'm doing wrong or what else I can try. Thanks!
Greg suggested using http://varnish-cache.org/wiki/VCLExampleLongerCaching and ignoring max-age which is a possibility but I would rather have the correct headers and not have to hack around them.