|
|
@@ -137,6 +137,8 @@ M.make_bytecode = function(conn)
|
|
|
utils.save_file(fw.website_dir().."/"..(fwutils_config.path.luabytecode:gsub("%.", "/")).."/template_engine_bc.lua",code)
|
|
|
return true
|
|
|
end
|
|
|
+
|
|
|
+
|
|
|
-- 处理
|
|
|
-- @param static_content 静态内容
|
|
|
-- @param cfg 配置
|
|
|
@@ -163,6 +165,7 @@ M.handle = function(__cfg,functions)
|
|
|
|
|
|
|
|
|
local ext = utils.ext(M.cfg.filepath())
|
|
|
+ local last_modified = fw.file_last_modified_time(fw.website_dir()..M.cfg.filepath())
|
|
|
local static_content = nil
|
|
|
if ext ~= nil then
|
|
|
if not has_ext(ext) then
|
|
|
@@ -176,7 +179,18 @@ M.handle = function(__cfg,functions)
|
|
|
else
|
|
|
-- 无需替换的扩展名
|
|
|
return false
|
|
|
- end
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 验证缓存
|
|
|
+ local if_modified_since = request.header("If-Modified-Since")
|
|
|
+ if if_modified_since ~= nil and if_modified_since ~= "" then
|
|
|
+ if if_modified_since == last_modified then
|
|
|
+ response.sendex("",304,"Not Modified")
|
|
|
+ return true
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
local template_engine_bc = require(fwutils_config.path.luabytecode..".template_engine_bc")
|
|
|
M.template_engine_bc_this_role["template"]["private"] = template_engine_bc[string.format("%d",M.cfg.role_id())]
|
|
|
M.template_engine_bc_this_role["template"]["public"] = template_engine_bc["public"]
|
|
|
@@ -214,11 +228,15 @@ M.handle = function(__cfg,functions)
|
|
|
end
|
|
|
|
|
|
if replaced then
|
|
|
+
|
|
|
if ext == "shtml" or ext == "html" then
|
|
|
response.header("Content-Type","text/html")
|
|
|
elseif ext == "js" then
|
|
|
response.header("Content-Type","application/javascript")
|
|
|
- end
|
|
|
+ end
|
|
|
+ -- print("Last-Modified:", last_modified)
|
|
|
+ response.header("Last-Modified", last_modified)
|
|
|
+ response.header("Cache-Control", "no-cache")
|
|
|
response.send(static_content)
|
|
|
return true
|
|
|
end
|