From 8c4a27c87ee1d7ae6b2924ef21489c6de8548935 Mon Sep 17 00:00:00 2001 From: Bram Date: Thu, 3 Jul 2025 13:22:19 +0200 Subject: [PATCH] fix pagination cache --- Dockers/puppeteer-api/app/database.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockers/puppeteer-api/app/database.py b/Dockers/puppeteer-api/app/database.py index 68731c8..b6e6733 100644 --- a/Dockers/puppeteer-api/app/database.py +++ b/Dockers/puppeteer-api/app/database.py @@ -90,9 +90,14 @@ def init_db(): def get_cached_data(url, route): conn = sqlite3.connect(DB_PATH) cursor = conn.cursor() - cache_expiry = int(time.time()) - (CACHE_EXPIRY_HOURS * 60 * 60) # Convert hours to seconds + + # Calculate cache expiry time if route == 'pagination': - cache_expiry = cache_expiry * 31 + # Pagination cache expires after 31 times the normal cache expiry + cache_expiry = int(time.time()) - (CACHE_EXPIRY_HOURS * 31 * 60 * 60) + else: + cache_expiry = int(time.time()) - (CACHE_EXPIRY_HOURS * 60 * 60) # Convert hours to seconds + cursor.execute( "SELECT data FROM cache WHERE url = ? AND route = ? AND timestamp > ?", (url, route, cache_expiry)