# HG changeset patch # User Kim Alvefur # Date 1355643290 -3600 # Node ID 13553f4132a8079063d310964e868fa8ee1b7d54 # Parent 9257f4c47ffa6234b322f14241fc951537ed8c83 mod_http_files: Compare If-Modified-Since to last modification date diff -r 9257f4c47ffa -r 13553f4132a8 plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Sun Dec 16 08:17:28 2012 +0100 +++ b/plugins/mod_http_files.lua Sun Dec 16 08:34:50 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