Mailing List Archive

varnishd config.
Hello,
I'm having som problems getting my varnish to work as i want to.
I'm running a minimal config:

backend default {
set backend.host = "<host>";
set backend.port = "<port>";
}

sub vcl_recv {
if (req.request == "GET" && req.url ~ "\.(gif|png|css|js)$") {
lookup;
}
}

When I go to the page it starts caching all the files and on reload all
the files are delivered from varnishd.
But when i go to a certain php on the page it forwards every request to
apache and when going back to one of the former working tabs they also go

I put a few expire-lines in my virtualhost-config:
ExpiresActive On
ExpiresByType image/gif "access plus 3 hours"
and so on, but it won't work.

Here are two examples of the headers tx:ed and rx:ed:
http://www.nangilima.se/varnishd/working.txt
http://www.nangilima.se/varnishd/nonworking.txt

I've noticed that in the working example apache provides last-modified
and a few other things in the response, but why doesn't it do that in
the nonworking?
Its the same virtualhost with all the same settings but another .php file.
I'm always using fully reload when testing so the browsers cache doesn't
lead me astray.

Thanks in advance
Regards Dan
varnishd config. [ In reply to ]
By default, Varnish doesn't cache any responses where cookies are
involved (in your case the php session id). There are a few messages
in the mailing list archive that explain how to override this behavior.

Jeff


On Oct 22, 2007, at 11:27 AM, Dan Deshayes wrote:

> Hello,
> I'm having som problems getting my varnish to work as i want to.
> I'm running a minimal config:
>
> backend default {
> set backend.host = "<host>";
> set backend.port = "<port>";
> }
>
> sub vcl_recv {
> if (req.request == "GET" && req.url ~ "\.(gif|png|css|js)$") {
> lookup;
> }
> }
>
> When I go to the page it starts caching all the files and on reload
> all
> the files are delivered from varnishd.
> But when i go to a certain php on the page it forwards every
> request to
> apache and when going back to one of the former working tabs they
> also go
>
> I put a few expire-lines in my virtualhost-config:
> ExpiresActive On
> ExpiresByType image/gif "access plus 3 hours"
> and so on, but it won't work.
>
> Here are two examples of the headers tx:ed and rx:ed:
> http://www.nangilima.se/varnishd/working.txt
> http://www.nangilima.se/varnishd/nonworking.txt
>
> I've noticed that in the working example apache provides last-modified
> and a few other things in the response, but why doesn't it do that in
> the nonworking?
> Its the same virtualhost with all the same settings but
> another .php file.
> I'm always using fully reload when testing so the browsers cache
> doesn't
> lead me astray.
>
> Thanks in advance
> Regards Dan
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>
varnishd config. [ In reply to ]
>

If you are not the intended recipient of this message (including attachments), or if you have received this message in error, immediately notify us and delete it and any attachments. If you no longer wish to receive e-mail from Edward Jones, please send this request to messages at edwardjones.com. You must include the e-mail address that you wish not to receive e-mail communications. For important additional information related to this e-mail, visit www.edwardjones.com/US_email_disclosure

-----Original Message-----


> From: varnish-misc-bounces at projects.linpro.no
[mailto:varnish-misc-bounces at projects.linpro.no] On Behalf
> Of Dan Deshayes
> Sent: Monday, October 22, 2007 4:27 AM
> To: varnish-misc
> Subject: varnishd config.
>
> When I go to the page it starts caching all the files and on reload
all the files are delivered from
> varnishd.
> But when i go to a certain php on the page it forwards every request
to apache and when going back to
> one of the former working tabs they also go
>
> From your headers I saw PHPSESSIONID, in that case you'll need some
logic to have it handle Auth or
> cookies. Here's my block on that:

For Auth/Cookies you need to tell Varnish to cache it, since the things
you're not caching are PHP pages, this is likely the issue. Here's the
block from my config:

##############
# AUTH #
##############
sub vcl_recv {
if (req.request != "GET" && req.request != "HEAD") {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
lookup;
}
pipe;
}
if (req.http.Expect) {
pipe;
}
if (req.http.Authenticate || req.http.Authorization) {
pass;
}
# We only care about the "__ac.*" cookies, used for
authentication
if (req.http.Cookie && req.http.Cookie ~
"__ac(|_(name|password|persistent))=") {
pass;
}
lookup;
}

See if that helps, I'm not 100% clear on all of the syntax in the last
sub-block, or if it's necessary in my case - I too am still learning. ;)

P