Skip to content

Instantly share code, notes, and snippets.

@briceburg
Created November 18, 2010 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briceburg/705251 to your computer and use it in GitHub Desktop.
Save briceburg/705251 to your computer and use it in GitHub Desktop.
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 30s;
.first_byte_timeout = 30s;
}
sub vcl_recv {
return(pipe);
set req.grace = 30m;
if (req.http.Accept-Encoding) {
if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
# No point in compressing these
remove req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
# unkown algorithm
remove req.http.Accept-Encoding;
}
}
if (req.url ~ "\.(png|css|js|jpg|jpeg|gif|ico|swf)$") {
unset req.http.cookie;
return (lookup);
}
}
sub vcl_fetch {
if (beresp.status == 500) {
set beresp.saintmode = 30s;
restart;
}
set beresp.grace = 30m;
if (req.url ~ "\.(png|css|js|jpg|jpeg|gif|ico|swf)$") {
unset beresp.http.set-cookie;
#set beresp.ttl = 5m;
}
}
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Lookup = "HIT";
} else {
set resp.http.X-Lookup = "MISS";
}
}
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html>
<head>
<title>Website Error</title>
</head>
<body>
<h1>Error "} obj.status " " obj.response {"</h1>
<p>"} obj.response {"</p>
</body>
</html>
"};
return (deliver);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment