Skip to content

Commit

Permalink
add an Expires header for the stylesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
madx committed Apr 7, 2010
1 parent 034d0ab commit d8261d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/haze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion views/layout.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"}
Expand Down

0 comments on commit d8261d2

Please sign in to comment.