diff --git a/src/lua/psl.lua b/src/lua/psl.lua index bc2f888..ff191c9 100644 --- a/src/lua/psl.lua +++ b/src/lua/psl.lua @@ -81,6 +81,14 @@ end function _M.get_registered_domain(domain) if not domain or domain == "" then return nil end + + local cache_key = "psl:" .. domain + local cache = ngx.shared.jasima_cache + local cached = cache:get(cache_key) + if cached then + return cached + end + local rules = load_psl() if not rules then return nil end @@ -101,7 +109,9 @@ function _M.get_registered_domain(domain) table.insert(reg_parts, domain_parts[i]) end - return table.concat(reg_parts, ".") + local result = table.concat(reg_parts, ".") + cache:set(cache_key, result, 86400 * 7) -- This is very unlikely to ever change + return result end return _M