Created
November 13, 2012 12:24
-
-
Save igorescobar/4065499 to your computer and use it in GitHub Desktop.
Varnish Grace Mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/varnish/default.vcl | |
# Define the list of backends (web servers). | |
# Port 80 Backend Servers | |
backend yourapp_webserver1 { | |
.host = "000.000.000.000"; | |
.port = "80"; | |
.max_connections = 250; | |
.connect_timeout = 5s; | |
.first_byte_timeout = 5s; | |
.between_bytes_timeout = 5s; | |
.probe = { | |
.url = "/"; | |
.interval = 3s; | |
.timeout = 2s; | |
.window = 3; | |
.threshold = 2; | |
} | |
} | |
# Define the director that determines how to distribute incoming requests. | |
director your_app round-robin { | |
{ .backend = your_app_webserver1; } | |
} | |
# VCL_RECV FUNCTION | |
if (req.http.host ~ "your\.host\.name\.com\.br" || req.http.host == "origin.your.host.name.com.br") { | |
set req.backend = your_app; | |
# defines how long an overdue an object can be for Varnish to still consider it for grace mode | |
set req.grace = 24h; | |
} | |
# VCL_FETCH FUNCTION | |
if (req.http.host ~ "your\.host\.name\.com\.br" || req.http.host == "origin.your.host.name.com.br") { | |
# defines how long past the beresp.ttl-time Varnish will keep an object | |
set beresp.grace = 24h; | |
# only caches the backend response when its status is lower than 500 | |
if (beresp.status >= 500) { | |
set beresp.ttl = 0s; | |
set beresp.cacheable = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment