Comparison

plugins/mod_http_files.lua @ 5248:13553f4132a8

mod_http_files: Compare If-Modified-Since to last modification date
author Kim Alvefur <zash@zash.se>
date Sun, 16 Dec 2012 08:34:50 +0100
parent 5247:9257f4c47ffa
child 5252:6209b9a0244b
comparison
equal deleted inserted replaced
5247:9257f4c47ffa 5248:13553f4132a8
55 local attr = stat(full_path); 55 local attr = stat(full_path);
56 if not attr then 56 if not attr then
57 return 404; 57 return 404;
58 end 58 end
59 59
60 response.headers.last_modified = os_date('!%a, %d %b %Y %H:%M:%S GMT', attr.modification); 60 local last_modified = os_date('!%a, %d %b %Y %H:%M:%S GMT', attr.modification);
61 response.headers.last_modified = last_modified;
61 62
62 local tag = ("%02x-%x-%x-%x"):format(attr.dev or 0, attr.ino or 0, attr.size or 0, attr.modification or 0); 63 local etag = ("%02x-%x-%x-%x"):format(attr.dev or 0, attr.ino or 0, attr.size or 0, attr.modification or 0);
63 response.headers.etag = tag; 64 response.headers.etag = etag;
64 if tag == request.headers.if_none_match then 65
66 if etag == request.headers.if_none_match
67 or last_modified == request.headers.if_modified_since then
65 return 304; 68 return 304;
66 end 69 end
67 70
68 local data = cache[path]; 71 local data = cache[path];
69 if data then 72 if data then