header_filter_by_lua_block {
ngx.header.content_length = nil
ngx.header["server"] = ngx.var.server_display_name
ngx.header["Server"] = ngx.var.server_display_name
}
if ngx.arg[1] ~= '' then
ngx.var.proxy_buffer_body = ngx.var.proxy_buffer_body..ngx.arg[1]
end
if ngx.arg[2] then
if ngx.var.needcacheuri=="1" then
local body = ngx.var.proxy_buffer_body
doreplace(body)
encodeurl = ngx.var.encodeuri
local ismatch = ngx.re.match(ngx.var.request_uri, ngx.var.shuffixfilter, "i")
if not ismatch and (ngx.status==200 or ngx.status==304) then
writefile(ngx.var.cachepathuri, "<!--{{cacheid="..encodeurl.."}}-->\n")
writefile(ngx.var.cachepathuri, "<!--{{cachefrom="..ngx.var.request_uri.."}}-->\n")
writefile(ngx.var.cachepathuri, ngx.arg[1])
end
else
local cache = readfile(ngx.var.cachepathuri)
ngx.arg[1] = cache
end
return