Created
June 17, 2010 22:13
-
-
Save travisbell/442877 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
# Default backend | |
backend apache { | |
.host ="127.0.0.1"; | |
.port = "8081"; | |
.max_connections = 100; | |
} | |
backend unicorn { | |
.host = "127.0.0.1"; | |
.port = "8082"; | |
.max_connections = 250; | |
} | |
acl purge { | |
"localhost"; | |
"68.144.18.239"; | |
} | |
sub vcl_recv { | |
if (req.url ~ "^/2.0") { | |
set req.backend = apache; | |
} | |
if (req.url ~ "^/2.1") { | |
set req.backend = unicorn; | |
} | |
# Handle special requests | |
if (req.request != "GET" && req.request != "HEAD") { | |
# POST - Logins and edits | |
if (req.request == "POST") { | |
return(pass); | |
} | |
# PURGE - The CacheFu product can invalidate updated URLs | |
if (req.request == "PURGE") { | |
if (!client.ip ~ purge) { | |
error 405 "Not allowed."; | |
} | |
return(lookup); | |
} | |
} | |
# Do a "lookup" in the cache. This goes to "vcl_hit", or to | |
# "vcl_miss" and then "vcl_fetch" | |
return(lookup); | |
# The default vcl_recv is used from here. | |
} | |
# Do the PURGE thing | |
sub vcl_hit { | |
if (req.request == "PURGE") { | |
set obj.ttl = 0s; | |
error 200 "Purged"; | |
} | |
} | |
sub vcl_miss { | |
if (req.request == "PURGE") { | |
error 404 "Not in cache"; | |
} | |
} | |
# Enforce a minimum TTL, since we can PURGE changed objects actively | |
sub vcl_fetch { | |
if (req.url ~ "^/2.1/Movie.search|^/2.1/Movie.getInfo") { | |
esi; /* Do ESI processing */ | |
} | |
if (req.url ~ "^/2.0/Movie.imdbLookup|^/2.0/Movie.getInfo") { | |
esi; /* Do ESI processing */ | |
} | |
} | |
sub vcl_deliver { | |
if (obj.hits > 0) { | |
set resp.http.X-Cache = "HIT"; | |
} else { | |
set resp.http.X-Cache = "MISS"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment