From 84dcecb046e820e0cd9541d6caa5e111c1ad4c8c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 11 Dec 2012 22:30:13 +0100 Subject: mod_http_files: Add ETag and check If-None-Match to allow client-side cache --- plugins/mod_http_files.lua | 7 +++++++ 1 file changed, 7 insertions(+) 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.."/"; -- cgit v1.2.3