diff --git a/assets/static/index.html b/assets/static/index.html
new file mode 100644
index 00000000..4a22cdb1
--- /dev/null
+++ b/assets/static/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+ Travis CI - Distributed Continuous Integration Platform for the Open Source Community
+
+
+
+
+
+
+
+
diff --git a/lib/travis/web/app.rb b/lib/travis/web/app.rb
index 5fb7ac9b..7c3f2c56 100644
--- a/lib/travis/web/app.rb
+++ b/lib/travis/web/app.rb
@@ -33,7 +33,8 @@ class Travis::Web::App
use Travis::Web::App::Api, config if config.run_api?
- use Rack::Cache, verbose: true, metastore: 'heap:/', entitystore: 'heap:/' if config.production?
+ # TODO breaks with wrong content length
+ # use Rack::Cache, verbose: true, metastore: 'heap:/', entitystore: 'heap:/' if config.production?
use Rack::Deflater if config.deflate?
use Travis::Web::App::Assets, config
diff --git a/lib/travis/web/app/files.rb b/lib/travis/web/app/files.rb
index e93b7e53..1c153331 100644
--- a/lib/travis/web/app/files.rb
+++ b/lib/travis/web/app/files.rb
@@ -1,5 +1,11 @@
class Travis::Web::App
class Files < Rack::Cascade
+ MUST_REVALIDATE = %w(/ /index.html /version)
+
+ def self.last_modified
+ @last_modified ||= File.mtime("public/version").httpdate
+ end
+
def initialize
super([public_dir, index])
end
@@ -11,9 +17,21 @@ class Travis::Web::App
def index
proc do |env|
status, headers, body = Rack::File.new(nil).tap { |f| f.path = 'public/index.html' }.serving(env)
- headers.delete 'Last-Modified'
+ headers.merge!(cache_headers(env['PATH_INFO'])) # TODO unless development?
[status, headers, body]
end
end
+
+ def cache_headers(path)
+ { 'Cache-Control' => cache_control(path), 'Last-Modified' => self.class.last_modified }
+ end
+
+ def cache_control(path)
+ must_revalidate?(path) ? 'public, must-revalidate' : 'public, max-age=31536000'
+ end
+
+ def must_revalidate?(path)
+ MUST_REVALIDATE.include?(path)
+ end
end
end
diff --git a/public/version b/public/version
index 1b5972f8..2f4def44 100644
--- a/public/version
+++ b/public/version
@@ -1 +1 @@
-2d6e5c78
\ No newline at end of file
+b9f79cf9
\ No newline at end of file