diff --git a/src/lua/psl.lua b/src/lua/psl.lua index 6ce88ba..bc2f888 100644 --- a/src/lua/psl.lua +++ b/src/lua/psl.lua @@ -1,3 +1,4 @@ +local cjson = require "cjson" local http = require "resty.http" local _M = {} @@ -26,10 +27,11 @@ end local function load_psl() local cache = ngx.shared.jasima_cache local cached = cache:get("psl") - if cached then return cached end + if cached then return cjson.decode(cached) end + ngx.log(ngx.DEBUG, "Cache miss on public suffix list") local rules, err = fetch_psl() if rules then - cache:set("psl", rules, 86400 * 7) -- 1 week + cache:set("psl", cjson.encode(rules), 86400 * 7) -- 1 week return rules else ngx.log(ngx.ERR, err or "Unknown error loading PSL")