diff options
author | Kim Alvefur <zash@zash.se> | 2012-12-11 22:30:13 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2012-12-11 22:30:13 +0100 |
commit | 84dcecb046e820e0cd9541d6caa5e111c1ad4c8c (patch) | |
tree | ae8448492d978b7d1c44489771fd8e7c6ed7acf7 /plugins/mod_http_files.lua | |
parent | ed92fd78b69d9f4c85aac61a96c0212ca40f4ebf (diff) | |
download | prosody-84dcecb046e820e0cd9541d6caa5e111c1ad4c8c.tar.gz prosody-84dcecb046e820e0cd9541d6caa5e111c1ad4c8c.zip |
mod_http_files: Add ETag and check If-None-Match to allow client-side cache
Diffstat (limited to 'plugins/mod_http_files.lua')
-rw-r--r-- | plugins/mod_http_files.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 8d3405c9..0add5c86 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -35,6 +35,13 @@ function serve_file(event, path) return 404; end + + 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 + return 304; + end + if attr.mode == "directory" then if full_path:sub(-1) ~= "/" then response.headers.location = orig_path.."/"; |