Skip to content

Instantly share code, notes, and snippets.

@acdha
Created April 12, 2012 15:38
Show Gist options
  • Save acdha/2368296 to your computer and use it in GitHub Desktop.
Save acdha/2368296 to your computer and use it in GitHub Desktop.
Basic Varnish configuration
backend default {
.host = ".......";
.port = "8080";
.connect_timeout = 15s;
.first_byte_timeout = 120s;
.between_bytes_timeout = 120s;
}
sub vcl_fetch {
set beresp.grace = 1h;
if (beresp.http.content-type ~ "(text|application)") {
set beresp.do_gzip = true;
}
}
sub vcl_recv {
# unset cookies since we don't want to bypass caching normally
if (req.http.cookie) {
unset req.http.cookie;
}
set req.grace = 1h;
}
sub vcl_deliver {
if (!resp.http.Vary) {
set resp.http.Vary = "Accept-Encoding";
} else if (resp.http.Vary !~ "(?i)Accept-Encoding") {
set resp.http.Vary = resp.http.Vary + ",Accept-Encoding";
}
}
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
set obj.http.Retry-After = "5";
synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>The page is temporarily unavailable</title>
</head>
<body>
<h1>Page temporarily unavailable</h1>
<p>
The page you are looking for on Chronicling America: Historic Newspapers is temporarily unavailable. We regret the inconvenience. Please try again later.
</p>
</body>
</html>
"};
return (deliver);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment