Skip to content

Commit

Permalink
Properly log local hits for 304s
Browse files Browse the repository at this point in the history
  • Loading branch information
maxjustus committed Feb 10, 2014
1 parent 34e3f52 commit bf9394c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/luchador/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ function Cache:serve()
end

local locally_cached
self.response.headers = self:get_stored_headers()
self.response.headers, locally_cached = self:get_stored_headers()

if self.response:check_not_modified() then
if locally_cached then self:record('local') end
self:not_modified()
else
if not self:get_page() then
Expand Down
2 changes: 1 addition & 1 deletion test/integration_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test("304s if etags matches If-None-Match", function()
local headers = get({["If-None-Match"] = "123"}, server_response_headers)

assert_match(headers, "304 Not Modified")
assert_match(headers, "X-Cache: hit")
assert_match(headers, "X-Cache: local hit")
end)

test("excludes disallowed 304 headers on 304", function()
Expand Down

0 comments on commit bf9394c

Please sign in to comment.