From 33eb6f6487adccd2c6f2ab341459ef129073981a Mon Sep 17 00:00:00 2001 From: gintil Date: Sat, 1 Feb 2025 10:21:29 -0500 Subject: [PATCH] Cap freshness lifetime to 1 hour Many feeds provide cache control values longer than what the feed xml says it should be --- .../utils/calculate-response-freshness-lifetime.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/services/feed-requests/src/shared/utils/calculate-response-freshness-lifetime.ts b/services/feed-requests/src/shared/utils/calculate-response-freshness-lifetime.ts index 04cfe6fb1..3ec46042b 100644 --- a/services/feed-requests/src/shared/utils/calculate-response-freshness-lifetime.ts +++ b/services/feed-requests/src/shared/utils/calculate-response-freshness-lifetime.ts @@ -4,16 +4,11 @@ const FALLBACK_VALUE = { }; const capFreshnessLifetime = (ms: number) => { - // If freshness lifetime is >= 1 year, consider it a bug and cap it to 1 hour - if (ms >= 365 * 24 * 60 * 60 * 1000) { + // If freshness lifetime is >= 1 hour, cap it to once per hour + if (ms >= 60 * 60 * 1000) { return 60 * 60 * 1000; } - // If freshness lifetime is 1 month, cap it to once a day - if (ms >= 30 * 24 * 60 * 60 * 1000) { - return 24 * 60 * 60 * 1000; - } - return ms; };