From 7c7e98953e06e6d622e7fe93970d91d99716bfe0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 16 Dec 2012 08:17:28 +0100 Subject: mod_http_files: Fix caching the stringified directory index --- plugins/mod_http_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 764991b8..92617b09 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -98,7 +98,7 @@ function serve_file(event, path) end end data = "\n"..tostring(html); - cache[path] = { data = html, content_type = mime_map.html; hits = 0 }; + cache[path] = { data = data, content_type = mime_map.html; hits = 0 }; response.headers.content_type = mime_map.html; end -- cgit v1.2.3 From eaba58e39b083025ae4236d3ef516b59c081d326 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 16 Dec 2012 08:34:50 +0100 Subject: mod_http_files: Compare If-Modified-Since to last modification date --- plugins/mod_http_files.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins') 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 -- cgit v1.2.3