Permalink
Browse files

testing varnish caching

  • Loading branch information...
1 parent 86ed8c6 commit 6fa92c9b7b148e41d65009c4dbe313b72b0ee49c @JackDanger JackDanger committed Oct 2, 2010
Showing with 10 additions and 5 deletions.
  1. +6 −5 lib/barcode_service.rb
  2. +4 −0 test.rb
View
@@ -11,17 +11,18 @@
get '/:code.:extension' do
- # begin
+ begin
options = request.env['rack.request.query_hash']
options = default_options.merge(options)
content_type "image/#{params[:extension]}"
+ headers['Cache-Control'] = "public, max-age=#{3600*24*365}"
Converter.encode params[:code], params[:extension], options
- # rescue => error
- # puts error.inspect
- # status 400
- # end
+ rescue => error
+ puts error.inspect
+ status 400
+ end
end
get '/' do
View
@@ -37,6 +37,10 @@ def app
should "return ok" do
assert last_response.ok?
end
+ should "cache for a year" do
+ assert_equal 'public, max-age=31536000',
+ last_response.headers['Cache-Control']
+ end
should "return #{format} content-type" do
assert_equal "image/#{format}", last_response.headers['Content-Type']
end

0 comments on commit 6fa92c9

Please sign in to comment.