diff --git a/package.json b/package.json index e0d09b9..86a600f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lustpress", - "version": "8.2.3-alpha", + "version": "8.2.4-alpha", "description": "RESTful and experimental API for PH and other R18 websites", "main": "src/index.ts", "scripts": { diff --git a/src/LustPress.ts b/src/LustPress.ts index d38cc84..e8dd2d8 100644 --- a/src/LustPress.ts +++ b/src/LustPress.ts @@ -9,7 +9,7 @@ const keyv = process.env.REDIS_URL : new Keyv(); keyv.on("error", (err) => console.log("Connection Error", err)); -const ttl = 1000 * 60 * 60 * Number(process.env.EXPIRE_CACHE); +const ttl = 1000 * 60 * 60 * Number(process.env.EXPIRE_CACHE || "1"); const GEO_TIMEOUT_MS = 3000; let cachedLastLocation: string | null = null; @@ -77,7 +77,10 @@ class LustPress { async fetchBody(url: string): Promise { const cached = await keyv.get(url); - if (cached) return cached; + if (cached) { + console.log(`[CACHE HIT] ${url}`); + return cached; + } const isPornhub = /pornhub\.com/i.test(url); const domain = new URL(url).hostname; @@ -96,6 +99,7 @@ class LustPress { headers["Accept-Language"] = "en-US,en;q=0.9"; } + console.log(`[FETCH] ${url}`); let res = await fetch(url, { headers, redirect: "follow" }); let text = await res.text();