Last active
February 1, 2018 10:34
-
-
Save gquintard/58ed35d2d2cd67a2e10d95a9baac4ae6 to your computer and use it in GitHub Desktop.
This file contains 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
vcl 4.0; /* don't mind that, that's the vcl version, not the varnish version*/ | |
import std; | |
backend api { | |
.host = "192.168.1.123"; | |
} | |
backend api_limited { | |
.host = "192.168.1.123"; | |
.max_connections = 10; | |
} | |
/* called when we receive a request (req) */ | |
sub vcl_recv { | |
set req.url = std.querysort(req.url); | |
} | |
/* called before sending the backend request (bereq) */ | |
sub vcl_backend_fetch { | |
if (bereq.is_bgfetch) { | |
set bereq.backend = api_limited; | |
} else { | |
set bereq.backend = api; | |
} | |
} | |
/* called when we receive the backend response (beresp) */ | |
sub vcl_backend_response { | |
/* check if the content-type header contains "application/xml" */ | |
if (beresp.http.content-type ~ "application/xml") { | |
set beresp.do_gzip = true; | |
} | |
set beresp.ttl = 5m; | |
set beresp.grace = 6h; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment