Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Misc

Help with caching and failover

 

 

Varnish misc RSS feed   Index | Next | Previous | View Threaded


nsabbi at officinedigitali

Aug 1, 2012, 9:25 AM

Post #1 of 3 (441 views)
Permalink
Help with caching and failover

Hi,
I'm trying to configure varnish 3.0.1 as a failover cache in front of a web
server running EZ publish.
What I'd like to do is to let varnish cache pages for up to 4 hours. If the
backend server is seen sick it should serve the last cached page for the
current request (if available), otherwise serve an error page.

The backend polling code is working fine, but every time I tamper with the
test page returning a 404 error code (in order to force the sick mode)
varnish returns a 503 error to the client instead of the cached content,
even though the cache is populated (or so I assume).

The configuration code I'm using is the following:


backend default {
.host = "192.168.0.66";
.port = "80";
.probe = {
.url = "http://backend/test.php";
.timeout = 10s;
.interval = 5s;
.window = 3;
.threshold = 3;
.expected_response=200;
}
}

sub vcl_recv {
if (req.backend.healthy) {
set req.grace = 30m;
} else {
set req.grace = 4h;
}
#return(lookup);
}

sub vcl_fetch {
set beresp.grace = 8h;
# return(restart);
}



sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
set obj.http.Retry-After = "5";
synthetic {"
Unavailable page!
"};
return (deliver);
}

Please, can you explain me what's missing or wrong with this configuration?
Thanks,
Nico


nick.tailor at gmail

Aug 1, 2012, 9:35 AM

Post #2 of 3 (422 views)
Permalink
Re: Help with caching and failover [In reply to]

Your missing set beresp.ttl

Cheers

Nick Tailor

Sent from my iPhone

On Aug 1, 2012, at 9:25 AM, nicola sabbi <nsabbi [at] officinedigitali> wrote:

> Hi,
> I'm trying to configure varnish 3.0.1 as a failover cache in front of a web server running EZ publish.
> What I'd like to do is to let varnish cache pages for up to 4 hours. If the backend server is seen sick it should serve the last cached page for the current request (if available), otherwise serve an error page.
>
> The backend polling code is working fine, but every time I tamper with the test page returning a 404 error code (in order to force the sick mode) varnish returns a 503 error to the client instead of the cached content, even though the cache is populated (or so I assume).
>
> The configuration code I'm using is the following:
>
>
> backend default {
> .host = "192.168.0.66";
> .port = "80";
> .probe = {
> .url = "http://backend/test.php";
> .timeout = 10s;
> .interval = 5s;
> .window = 3;
> .threshold = 3;
> .expected_response=200;
> }
> }
>
> sub vcl_recv {
> if (req.backend.healthy) {
> set req.grace = 30m;
> } else {
> set req.grace = 4h;
> }
> #return(lookup);
> }
>
> sub vcl_fetch {
> set beresp.grace = 8h;
> # return(restart);
> }
>
>
>
> sub vcl_error {
> set obj.http.Content-Type = "text/html; charset=utf-8";
> set obj.http.Retry-After = "5";
> synthetic {"
> Unavailable page!
> "};
> return (deliver);
> }
>
> Please, can you explain me what's missing or wrong with this configuration?
> Thanks,
> Nico
> _______________________________________________
> varnish-misc mailing list
> varnish-misc [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


nsabbi at officinedigitali

Aug 2, 2012, 9:30 AM

Post #3 of 3 (421 views)
Permalink
Re: Help with caching and failover [In reply to]

Hi,
I modified vcl_fetch as follows:

sub vcl_fetch {

set beresp.grace = 8h;
set beresp.ttl = 8h;

# return(restart);
}


but still Varnish is not showing cached content when the polling page goes
down.
May it have to do with the headers sent by EZ?




HTTP/1.1 200 OK
Server: Apache/2.2.14 (Ubuntu)
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified: Thu, 02 Aug 2012 16:26:26 GMT
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
X-Powered-By: eZ Publish
Served-by: xxxxxxxxxx
Content-language: it-IT
Vary: Accept-Encoding
Content-Type: text/html; charset=utf-8
Date: Thu, 02 Aug 2012 16:26:26 GMT
X-Varnish: 447384858
Age: 0
Via: 1.1 varnish
Connection: close

Since the expiration date is always in the past and the last-modified
header is always set to now() I added

unset beresp.http.expires;

at the very beginning of vcl_fetch, but I didn't get any improvement.


Thanks,
Nico

Varnish misc RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.