Skip to content

Commit

Permalink
Remove server mtime checking
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Nov 20, 2011
1 parent a5c398f commit caa378d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
11 changes: 2 additions & 9 deletions lib/sprockets/server.rb
Expand Up @@ -53,9 +53,8 @@ def call(env)
# Return a 404 Not Found
not_found_response

# Check request headers `HTTP_IF_MODIFIED_SINCE` and
# `HTTP_IF_NONE_MATCH` against the assets mtime and digest
elsif not_modified?(asset, env) || etag_match?(asset, env)
# Check request headers `HTTP_IF_NONE_MATCH` against the asset digest
elsif etag_match?(asset, env)
logger.info "#{msg} 304 Not Modified (#{time_elapsed.call}ms)"

# Return a 304 Not Modified
Expand Down Expand Up @@ -174,12 +173,6 @@ def escape_css_content(content)
gsub('/', '\\\\002f ')
end

# Compare the requests `HTTP_IF_MODIFIED_SINCE` against the
# assets mtime
def not_modified?(asset, env)
env["HTTP_IF_MODIFIED_SINCE"] == asset.mtime.httpdate
end

# Compare the requests `HTTP_IF_NONE_MATCH` against the assets digest
def etag_match?(asset, env)
env["HTTP_IF_NONE_MATCH"] == etag(asset)
Expand Down
17 changes: 0 additions & 17 deletions test/test_server.rb
Expand Up @@ -124,23 +124,6 @@ def app
assert_equal time_before_touching, time_after_touching
end

test "not modified response when headers match" do
get "/assets/application.js"
assert_equal 200, last_response.status

path = fixture_path "server/app/javascripts/bar.js"
mtime = Time.now + 1
File.utime(mtime, mtime, path)

get "/assets/bar.js", {},
'HTTP_IF_MODIFIED_SINCE' =>
File.mtime(fixture_path("server/app/javascripts/bar.js")).httpdate

assert_equal 304, last_response.status
assert_equal nil, last_response.headers['Content-Type']
assert_equal nil, last_response.headers['Content-Length']
end

test "not modified partial response when etags match" do
get "/assets/application.js?body=1"
assert_equal 200, last_response.status
Expand Down

0 comments on commit caa378d

Please sign in to comment.