feat: add CACHE_SECONDS environment variable (#2266)

* feat: add CACHE_SECONDS environment variable

This commit adds the CACHE_SECONDS environment variable. This variable
can be used to circumvent our cache clamping values for self hosted
Vercel instances.

* refactor: apply formatter
This commit is contained in:
Rick Staa
2023-06-09 03:44:42 +02:00
committed by GitHub
parent 38c8a7a1e4
commit 3e66189c44
5 changed files with 59 additions and 19 deletions
+4 -1
View File
@@ -55,11 +55,14 @@ export default async (req, res) => {
parseArray(exclude_repo),
);
const cacheSeconds = clampValue(
let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
CONSTANTS.FOUR_HOURS,
CONSTANTS.ONE_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;
res.setHeader(
"Cache-Control",
+3
View File
@@ -44,6 +44,9 @@ export default async (req, res) => {
CONSTANTS.FOUR_HOURS,
CONSTANTS.ONE_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;
/*
if star count & fork count is over 1k then we are kFormating the text
+4 -1
View File
@@ -62,11 +62,14 @@ export default async (req, res) => {
count_weight,
);
const cacheSeconds = clampValue(
let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
CONSTANTS.FOUR_HOURS,
CONSTANTS.ONE_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;
res.setHeader(
"Cache-Control",
+3
View File
@@ -46,6 +46,9 @@ export default async (req, res) => {
CONSTANTS.FOUR_HOURS,
CONSTANTS.ONE_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;
if (!cache_seconds) {
cacheSeconds = CONSTANTS.FOUR_HOURS;