Set expires to and max-age to 0 for index.html

This ensures that chrome will not indifinitely cache the index.html file.
This commit is contained in:
Piotr Sarnacki 2015-02-06 10:54:23 +01:00
parent 3f7a9df8ba
commit 9591fdc4c6

View File

@ -87,7 +87,7 @@ class Travis::Web::App
'Cache-Control' => cache_control(file), 'Cache-Control' => cache_control(file),
'Content-Location' => path_for(file), 'Content-Location' => path_for(file),
'Content-Type' => mime_type(file), 'Content-Type' => mime_type(file),
'Expires' => (server_start + age).httpdate, 'Expires' => expires(file),
'ETag' => fingerprint(file) 'ETag' => fingerprint(file)
} }
else else
@ -100,7 +100,7 @@ class Travis::Web::App
'Content-Location' => path_for(file), 'Content-Location' => path_for(file),
'Content-Type' => mime_type(file), 'Content-Type' => mime_type(file),
'Last-Modified' => server_start.httpdate, 'Last-Modified' => server_start.httpdate,
'Expires' => (server_start + age).httpdate, 'Expires' => expires(file),
'Vary' => vary_for(file), 'Vary' => vary_for(file),
'ETag' => Digest::MD5.hexdigest(content) 'ETag' => Digest::MD5.hexdigest(content)
} }
@ -132,11 +132,18 @@ class Travis::Web::App
def cache_control(file) def cache_control(file)
case path_for(file) case path_for(file)
when '/' then "public, must-revalidate" when '/' then "public, must-revalidate, max-age=0"
else "public, max-age=#{age}" else "public, max-age=#{age}"
end end
end end
def expires(file)
case path_for(file)
when '/' then '0'
else (server_start + age).httpdate
end
end
def vary_for(file) def vary_for(file)
case path_for(file) case path_for(file)
when '/' then 'Accept' when '/' then 'Accept'