Permalink
Browse files

add an Expires header for the stylesheet

  • Loading branch information...
1 parent 034d0ab commit d8261d2df641b306d6f015da15898d95c0808d73 @madx committed Apr 7, 2010
Showing with 6 additions and 1 deletion.
  1. +5 −0 lib/haze.rb
  2. +1 −1 views/layout.haml
View
@@ -161,6 +161,10 @@ def try_path(path)
not_found unless File.exist?(path)
return path
end
+
+ def stylesheet_url
+ "/stylesheet.css?#{File.mtime('stylesheet.css').to_i}"
+ end
end
get '/' do
@@ -207,6 +211,7 @@ def try_path(path)
get '/stylesheet.css' do
content_type 'text/css'
+ response['Expires'] = (Time.now + 60*60*24*365).httpdate
File.read 'stylesheet.css'
end
View
@@ -3,7 +3,7 @@
%head
%title= make_title
%meta{'http-equiv' => 'Content-Type', :content => 'text/html;charset=utf-8'}
- %link{:rel => "stylesheet", :href => "/stylesheet.css",
+ %link{:rel => "stylesheet", :href => stylesheet_url,
:media => "screen", :type => "text/css"}
%link{:rel => "alternate", :type => "application/atom+xml",
:href => "/feed", :title => "#{Haze.opt :title} (Atom 0.3)"}

0 comments on commit d8261d2

Please sign in to comment.