Unverified Commit ec246d27 authored by Anurag Hazra's avatar Anurag Hazra Committed by GitHub
Browse files

fix: increase cache

parent 8fed8019
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -42,8 +42,8 @@ module.exports = async (req, res) => {
  }

  const cacheSeconds = clampValue(
    parseInt(cache_seconds || CONSTANTS.THIRTY_MINUTES, 10),
    CONSTANTS.THIRTY_MINUTES,
    parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
    CONSTANTS.TWO_HOURS,
    CONSTANTS.ONE_DAY
  );

+3 −3
Original line number Diff line number Diff line
@@ -32,8 +32,8 @@ module.exports = async (req, res) => {
  }

  let cacheSeconds = clampValue(
    parseInt(cache_seconds || CONSTANTS.THIRTY_MINUTES, 10),
    CONSTANTS.THIRTY_MINUTES,
    parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
    CONSTANTS.TWO_HOURS,
    CONSTANTS.ONE_DAY
  );

@@ -47,7 +47,7 @@ module.exports = async (req, res) => {
  const isBothOver1K = stars > 1000 && forks > 1000;
  const isBothUnder1 = stars < 1 && forks < 1;
  if (!cache_seconds && (isBothOver1K || isBothUnder1)) {
    cacheSeconds = CONSTANTS.TWO_HOURS;
    cacheSeconds = CONSTANTS.FOUR_HOURS;
  }

  res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
+2 −2
Original line number Diff line number Diff line
@@ -34,8 +34,8 @@ module.exports = async (req, res) => {
  }

  const cacheSeconds = clampValue(
    parseInt(cache_seconds || CONSTANTS.THIRTY_MINUTES, 10),
    CONSTANTS.THIRTY_MINUTES,
    parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
    CONSTANTS.TWO_HOURS,
    CONSTANTS.ONE_DAY
  );

+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ You can provide multiple comma saperated values in bg_color option to render a g
&bg_color=DEG,COLOR1,COLRO2,COLOR3...COLOR10
```

> Note on cache: Repo cards have default cache of 30mins (1800 seconds) if the fork count & star count is less than 1k otherwise it's 2hours (7200). Also note that cache is clamped to minimum of 30min and maximum of 24hours
> Note on cache: Repo cards have default cache of 4hours (14400 seconds) if the fork count & star count is less than 1k otherwise it's 2hours (7200). Also note that cache is clamped to minimum of 2hours and maximum of 24hours

#### Stats Card Exclusive Options:

+1 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ const logger =
const CONSTANTS = {
  THIRTY_MINUTES: 1800,
  TWO_HOURS: 7200,
  FOUR_HOURS: 14400,
  ONE_DAY: 86400,
};

Loading