Skip to content

Instantly share code, notes, and snippets.

@onethumb
Created May 14, 2014 18:16
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 onethumb/e64a405cc579909cace1 to your computer and use it in GitHub Desktop.
Save onethumb/e64a405cc579909cace1 to your computer and use it in GitHub Desktop.
vcl 4.0;
import directors;
probe health {
.url = "/ping/";
.expected_response = 200;
.timeout = 1s;
.interval = 1s;
}
backend instance1 {
.host = "10.100.18.112";
.port = "80";
.probe = health;
}
backend instance2 {
.host = "10.100.19.233";
.port = "80";
.probe = health;
}
sub vcl_init {
new PhotoServe = directors.round_robin();
PhotoServe.add_backend(instance1);
PhotoServe.add_backend(instance2);
}
sub vcl_recv {
if(req.url ~ "\.(jpg|gif|png|mp4)$") {
set req.backend_hint = PhotoServe.backend();
return(hash);
}
if(req.url ~ ".smil/") {
set req.backend_hint = PhotoServe.backend();
return(hash);
}
}
sub vcl_backend_response {
if(beresp.http.Content-Type ~ "video") {
set beresp.do_stream = true;
set beresp.do_gzip = false;
//set resp.http.Content-Length = beresp.http.Content-Length;
}
if(beresp.http.Edge-Control == "no-store") {
set beresp.uncacheable = true;
set beresp.ttl = 60s;
set beresp.http.Smug-Cacheable = "No";
return(deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment