mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-08-06 06:24:06 +00:00
feat: improve card loading speed (#2124)
* feat: improve card loading times This commit adds the `stale-while-revalidate` option to speed up the card loading times. * mend
This commit is contained in:
+6
-1
@@ -61,7 +61,12 @@ export default async (req, res) => {
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
|
||||
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=${
|
||||
cacheSeconds / 2
|
||||
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
);
|
||||
|
||||
return res.send(
|
||||
renderStatsCard(stats, {
|
||||
|
||||
+6
-1
@@ -58,7 +58,12 @@ export default async (req, res) => {
|
||||
cacheSeconds = CONSTANTS.FOUR_HOURS;
|
||||
}
|
||||
|
||||
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=${
|
||||
cacheSeconds / 2
|
||||
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
);
|
||||
|
||||
return res.send(
|
||||
renderRepoCard(repoData, {
|
||||
|
||||
+6
-1
@@ -52,7 +52,12 @@ export default async (req, res) => {
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
|
||||
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=${
|
||||
cacheSeconds / 2
|
||||
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
);
|
||||
|
||||
return res.send(
|
||||
renderTopLanguages(topLangs, {
|
||||
|
||||
+6
-1
@@ -52,7 +52,12 @@ export default async (req, res) => {
|
||||
cacheSeconds = CONSTANTS.FOUR_HOURS;
|
||||
}
|
||||
|
||||
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=${
|
||||
cacheSeconds / 2
|
||||
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
);
|
||||
|
||||
return res.send(
|
||||
renderWakatimeCard(stats, {
|
||||
|
||||
Reference in New Issue
Block a user