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)