aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-12-11 22:30:13 +0100
committerKim Alvefur <zash@zash.se>2012-12-11 22:30:13 +0100
commit48bb0d814ebfdbdfc49017592444e7fad0358ed6 (patch)
treeae8448492d978b7d1c44489771fd8e7c6ed7acf7 /plugins
parent896dda62653222978ed0cf849ca950d7963a6db4 (diff)
downloadprosody-48bb0d814ebfdbdfc49017592444e7fad0358ed6.tar.gz
prosody-48bb0d814ebfdbdfc49017592444e7fad0358ed6.zip
mod_http_files: Add ETag and check If-None-Match to allow client-side cache
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_http_files.lua7
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.."/";