diff options
author | Kim Alvefur <zash@zash.se> | 2012-12-16 08:34:50 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2012-12-16 08:34:50 +0100 |
commit | cf3f554dbc9cba6b90f60e9334f581d602e0d4df (patch) | |
tree | c604c2a76b0d571da3c39a2b8505ca1a538f4f3a | |
parent | 3d23a687aae9b675f20fbf7235428323b4da58cc (diff) | |
download | prosody-cf3f554dbc9cba6b90f60e9334f581d602e0d4df.tar.gz prosody-cf3f554dbc9cba6b90f60e9334f581d602e0d4df.zip |
mod_http_files: Compare If-Modified-Since to last modification date
-rw-r--r-- | plugins/mod_http_files.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 92617b09..d83e6f97 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -57,11 +57,14 @@ function serve_file(event, path) 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 |