-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
166 additions
and
49 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.git | ||
test-nginx | ||
Makefile | ||
test.rb |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
test: | ||
ruby test.rb | ||
|
||
|
||
test-up: | ||
cd test-nginx && docker build -t docker-varnish-test-nginx . && docker run -d --name docker-varnish-test-nginx docker-varnish-test-nginx | ||
docker build -t docker-varnish-test . && docker run -d --name docker-varnish-test --link docker-varnish-test-nginx:backend -p 8080:80 docker-varnish-test | ||
|
||
test-destroy: | ||
docker kill docker-varnish-test docker-varnish-test-nginx || true | ||
docker rm docker-varnish-test docker-varnish-test-nginx || true | ||
docker rmi docker-varnish-test docker-varnish-test-nginx || true | ||
|
||
clean: test-destroy | ||
|
||
.PHONY: test test-up test-destroy |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM nginx | ||
COPY nginx.conf /etc/nginx/nginx.conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
user nginx; | ||
worker_processes auto; | ||
|
||
error_log /dev/stdout info; | ||
|
||
events { | ||
worker_connections 1024; | ||
multi_accept on; | ||
use epoll; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
server_tokens off; | ||
access_log off; | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
chunked_transfer_encoding on; | ||
|
||
keepalive_timeout 30; | ||
|
||
client_max_body_size 2m; | ||
|
||
server { | ||
listen 80 default_server; | ||
server_name _; | ||
|
||
location /cache/1s { | ||
add_header "cache-control" "max-age=1"; | ||
return 200 'ok'; | ||
} | ||
|
||
location /cache/forever { | ||
add_header "cache-control" "max-age=31536000"; | ||
return 200 'ok'; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
|
||
require 'open-uri' | ||
|
||
|
||
base = "http://#{`boot2docker ip`.chomp}:8080" | ||
|
||
|
||
|
||
|
||
|
||
# Test 1 second TTL. | ||
|
||
open("#{base}/cache/1s") do |f| | ||
raise "wrong max-age header \"#{f.meta['cache-control']}\"" if f.meta['cache-control'] != 'max-age=1' | ||
xvarnish = f.meta['x-varnish'].split(' ') | ||
raise 'varnish cache miss on cached content' if xvarnish.length != 1 | ||
end | ||
|
||
sleep(1) | ||
|
||
open("#{base}/cache/1s") do |f| | ||
raise "wrong max-age header \"#{f.meta['cache-control']}\"" if f.meta['cache-control'] != 'max-age=1' | ||
xvarnish = f.meta['x-varnish'].split(' ') | ||
raise 'varnish cache hit on content that should have expired' if xvarnish.length != 2 | ||
end | ||
|
||
|
||
# Test max TTL. | ||
|
||
open("#{base}/cache/forever") do |f| | ||
raise "wrong max-age header \"#{f.meta['cache-control']}\"" if f.meta['cache-control'] != 'max-age=1' | ||
xvarnish = f.meta['x-varnish'].split(' ') | ||
raise 'varnish cache miss on cached content' if xvarnish.length != 1 | ||
end | ||
|
||
sleep(1) | ||
|
||
open("#{base}/cache/forever") do |f| | ||
raise "wrong max-age header \"#{f.meta['cache-control']}\"" if f.meta['cache-control'] != 'max-age=1' | ||
xvarnish = f.meta['x-varnish'].split(' ') | ||
raise 'varnish cache hit on content that should have expired' if xvarnish.length != 2 | ||
end | ||
|
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