Created
March 16, 2010 11:02
-
-
Save joshk/333846 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
backend default { | |
.host = "127.0.0.1"; | |
.port = "8000"; | |
} | |
sub vcl_recv { | |
if (req.request != "GET" | |
&& req.request != "HEAD") { | |
return (pass); | |
} | |
if (req.http.if-none-match == "%22cacheme%22") { | |
error 304 "Not Modified"; | |
} | |
call normalize_compression; | |
# call normalize_request; | |
return (lookup); | |
} | |
# sub normalize_request { | |
# if (req.url !~ "^/f/" | |
# && req.url !~ "^/l10n/" ) { | |
# set req.http.host = "img.blah.blah"; | |
# } | |
# no signature | |
# /f/spot/: homepage top5 | |
# /f/tiny/: thumbnails adv page | |
# /f/markt\d/: lijstuitvoer | |
# signature | |
# /f/preview/: main pics big adv page | |
# /f/normal/: lytebox main pics adv page | |
# } | |
sub normalize_compression { | |
# normalize compression, prefer gzip | |
if (req.http.Accept-Encoding) { | |
if (req.url ~ "\.(ico|jpe?g|png|gif|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|r\d\d|ace)$") { | |
# no point in compressing these | |
remove req.http.Accept-Encoding; | |
} elsif (req.http.Accept-Encoding ~ "gzip") { | |
set req.http.Accept-Encoding = "gzip"; | |
} elsif (req.http.Accept-Encoding ~ "deflate") { | |
set req.http.Accept-Encoding = "deflate"; | |
} else { | |
# unkown algorithm | |
remove req.http.Accept-Encoding; | |
} | |
} | |
} | |
sub vcl_fetch { | |
if (obj.cacheable) { | |
unset obj.http.set-cookie; | |
set obj.http.etag = "%22cacheme%22"; | |
return (deliver); | |
} else { | |
return (pass); | |
} | |
} | |
sub vcl_error { | |
if (obj.status == 304) { | |
set obj.http.X-Varnish = "304 Not Modified"; | |
deliver; | |
} | |
} |
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
#!/bin/sh | |
echo starting varnish daemon | |
/usr/local/varnish-2.0.6/sbin/varnishd \ | |
-s malloc,3G \ | |
-a 0.0.0.0:7999 \ | |
-p sess_timeout=3 \ | |
-p thread_pool_min=200 \ | |
-p thread_pool_max=4000 \ | |
-p thread_pools=4 \ | |
-p listen_depth=1024 \ | |
-p lru_interval=5 \ | |
-p obj_workspace=4096 \ | |
-f /home/blah/blah/setup/varnish/img_server_cache.vcl | |
echo done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment