Skip to content

Instantly share code, notes, and snippets.

@gquintard
Last active February 1, 2018 10:34
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 gquintard/58ed35d2d2cd67a2e10d95a9baac4ae6 to your computer and use it in GitHub Desktop.
Save gquintard/58ed35d2d2cd67a2e10d95a9baac4ae6 to your computer and use it in GitHub Desktop.
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