# HG changeset patch # User Kim Alvefur # Date 1356074709 -3600 # Node ID bf34f1ee08eee6a40902566606324a47f828130f # Parent df35528220544df2a65c714389cb48d8bf1856ec mod_http_files: Only serve cached data if etag is unchanged. diff -r df3552822054 -r bf34f1ee08ee plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Fri Dec 21 08:19:58 2012 +0100 +++ b/plugins/mod_http_files.lua Fri Dec 21 08:25:09 2012 +0100 @@ -73,7 +73,7 @@ end local data = cache[path]; - if data then + if data and data.etag == etag then response_headers.content_type = data.content_type; data = data.data; elseif attr.mode == "directory" then @@ -105,7 +105,7 @@ end end data = "\n"..tostring(html); - cache[path] = { data = data, content_type = mime_map.html; hits = 0 }; + cache[path] = { data = data, content_type = mime_map.html; etag = etag; }; response_headers.content_type = mime_map.html; end @@ -120,7 +120,7 @@ end local ext = path:match("%.([^./]+)$"); local content_type = ext and mime_map[ext]; - cache[path] = { data = data; content_type = content_type; }; + cache[path] = { data = data; content_type = content_type; etag = etag }; response_headers.content_type = content_type; end