cache_path = "/var/www/site/tmp" cache_code = "compile" -- render and cache to the filesystem function cache_gen() lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. "/index.php" lighty.env["uri.query"] = "p=" .. string.gsub(lighty.env["uri.path"], "\.(htm|html)$", "") --print ("CACHE: " .. lighty.env["uri.query"]) end -- load the cached copy from the filesystem function cache_load() lighty.env["physical.path"] = cache_path .. lighty.env["uri.path"] --print ("LOAD: " .. cache_path .. lighty.env["uri.path"]) end -- add index file if directory listing requested if(lighty.env["uri.path"] == "" or string.find(lighty.env["uri.path"], "/", -1)) then lighty.env["uri.path"] = lighty.env["uri.path"] .. "index.html" end -- process htm|html file requests if(string.find(lighty.env["uri.path"], "htm", -4)) then exists = lighty.stat(cache_path .. lighty.env["uri.path"]) cache_code_passed = false if(lighty.env["uri.query"] ) then cache_code_passed = string.find(lighty.env["uri.query"], cache_code) end if(exists and not cache_code_passed) then action = cache_load() else action = cache_gen() end end