Skip to content

Commit

Permalink
Cap freshness lifetime to 1 hour
Browse files Browse the repository at this point in the history
Many feeds provide cache control values longer than what the feed xml says it should be
  • Loading branch information
synzen committed Feb 1, 2025
1 parent c672b8d commit 33eb6f6
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit 33eb6f6

Please sign in to comment.