# HG changeset patch # User Kim Alvefur # Date 1355261413 -3600 # Node ID a9f0a1becc6664cca9b146311791d147ac6f6733 # Parent 342c46e62f5044a9dbfe211a1ca24a22bcc153d1 mod_http_files: Add ETag and check If-None-Match to allow client-side cache diff -r 342c46e62f50 -r a9f0a1becc66 plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Tue Dec 11 22:26:41 2012 +0100 +++ b/plugins/mod_http_files.lua Tue Dec 11 22:30:13 2012 +0100 @@ -35,6 +35,13 @@ 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.."/";