# HG changeset patch # User Kim Alvefur # Date 1355643434 -3600 # Node ID d1baef49be21dc95d33b4a5831c72020fe65e692 # Parent eba55873ef2967c0c491789b920a51695cc3dbf4# Parent 13553f4132a8079063d310964e868fa8ee1b7d54 Merge 0.9->trunk diff -r eba55873ef29 -r d1baef49be21 plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Sat Dec 15 05:35:43 2012 +0100 +++ b/plugins/mod_http_files.lua Sun Dec 16 08:37:14 2012 +0100 @@ -57,11 +57,14 @@ return 404; end - response.headers.last_modified = os_date('!%a, %d %b %Y %H:%M:%S GMT', attr.modification); + local last_modified = os_date('!%a, %d %b %Y %H:%M:%S GMT', attr.modification); + response.headers.last_modified = last_modified; - local tag = ("%02x-%x-%x-%x"):format(attr.dev or 0, attr.ino or 0, attr.size or 0, attr.modification or 0); - response.headers.etag = tag; - if tag == request.headers.if_none_match then + local etag = ("%02x-%x-%x-%x"):format(attr.dev or 0, attr.ino or 0, attr.size or 0, attr.modification or 0); + response.headers.etag = etag; + + if etag == request.headers.if_none_match + or last_modified == request.headers.if_modified_since then return 304; end @@ -98,7 +101,7 @@ end end data = "\n"..tostring(html); - cache[path] = { data = html, content_type = mime_map.html; hits = 0 }; + cache[path] = { data = data, content_type = mime_map.html; hits = 0 }; response.headers.content_type = mime_map.html; end