Skip to content

Commit

Permalink
Send a blank response with 304
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Feb 17, 2010
1 parent 0fdd64c commit 4bc77f0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vendor/plugins/themes/lib/theme_server.rb
@@ -1,7 +1,7 @@
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)

# Servers theme files from the them directory without touching Rails too much
# Serves theme files from the theme directory without touching Rails too much
class ThemeServer

def initialize(app)
Expand All @@ -15,13 +15,14 @@ def call(env)
if (file_path = Rails.root.join("themes", RefinerySetting[:theme], relative_path)).exist?
# generate an etag for client-side caching.
etag = Digest::MD5.hexdigest("#{file_path.to_s}#{file_path.mtime}")
unless (env["HTTP_IF_NONE_MATCH"] == etag and RefinerySetting.find_or_set(:themes_use_etags, false))
unless (env["HTTP_IF_NONE_MATCH"] == etag and RefinerySetting.find_or_set(:themes_use_etags, false) == true)
[200, {
"Content-Type" => Rack::Mime.mime_type(file_path.extname),
"Cache-Control" => "public",
"ETag" => etag
}, file_path.open]
else
[304, {"Content-Type" => Rack::Mime.mime_type(file_path.extname)}, "Not Modified"]
[304, {}, []]
end
else
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
Expand Down

0 comments on commit 4bc77f0

Please sign in to comment.