Diff

plugins/mod_http_files.lua @ 5255:bf34f1ee08ee

mod_http_files: Only serve cached data if etag is unchanged.
author Kim Alvefur <zash@zash.se>
date Fri, 21 Dec 2012 08:25:09 +0100
parent 5254:df3552822054
child 5256:a77c6eba461e
line wrap: on
line diff
--- a/plugins/mod_http_files.lua	Fri Dec 21 08:19:58 2012 +0100
+++ b/plugins/mod_http_files.lua	Fri Dec 21 08:25:09 2012 +0100
@@ -73,7 +73,7 @@
 	end
 
 	local data = cache[path];
-	if data then
+	if data and data.etag == etag then
 		response_headers.content_type = data.content_type;
 		data = data.data;
 	elseif attr.mode == "directory" then
@@ -105,7 +105,7 @@
 				end
 			end
 			data = "<!DOCTYPE html>\n"..tostring(html);
-			cache[path] = { data = data, content_type = mime_map.html; hits = 0 };
+			cache[path] = { data = data, content_type = mime_map.html; etag = etag; };
 			response_headers.content_type = mime_map.html;
 		end
 
@@ -120,7 +120,7 @@
 		end
 		local ext = path:match("%.([^./]+)$");
 		local content_type = ext and mime_map[ext];
-		cache[path] = { data = data; content_type = content_type; };
+		cache[path] = { data = data; content_type = content_type; etag = etag };
 		response_headers.content_type = content_type;
 	end