From 9591fdc4c66c2f6a327dde52b67539320fc01249 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 6 Feb 2015 10:54:23 +0100 Subject: [PATCH] Set expires to and max-age to 0 for index.html This ensures that chrome will not indifinitely cache the index.html file. --- waiter/lib/travis/web/app.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/waiter/lib/travis/web/app.rb b/waiter/lib/travis/web/app.rb index af5c1b26..ed81a768 100644 --- a/waiter/lib/travis/web/app.rb +++ b/waiter/lib/travis/web/app.rb @@ -87,7 +87,7 @@ class Travis::Web::App 'Cache-Control' => cache_control(file), 'Content-Location' => path_for(file), 'Content-Type' => mime_type(file), - 'Expires' => (server_start + age).httpdate, + 'Expires' => expires(file), 'ETag' => fingerprint(file) } else @@ -100,7 +100,7 @@ class Travis::Web::App 'Content-Location' => path_for(file), 'Content-Type' => mime_type(file), 'Last-Modified' => server_start.httpdate, - 'Expires' => (server_start + age).httpdate, + 'Expires' => expires(file), 'Vary' => vary_for(file), 'ETag' => Digest::MD5.hexdigest(content) } @@ -132,11 +132,18 @@ class Travis::Web::App def cache_control(file) case path_for(file) - when '/' then "public, must-revalidate" + when '/' then "public, must-revalidate, max-age=0" else "public, max-age=#{age}" end end + def expires(file) + case path_for(file) + when '/' then '0' + else (server_start + age).httpdate + end + end + def vary_for(file) case path_for(file) when '/' then 'Accept'