refactor: improve cache control headers formatting (#4536)
Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
This commit is contained in:
committed by
martin-mfg
co-authored by
Alexandr
parent
b687bf30bb
commit
b119e6a61c
@@ -31,7 +31,9 @@ const resolveCacheSeconds = ({ requested, def, min, max }) => {
|
||||
const setCacheHeaders = (res, cacheSeconds) => {
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=${cacheSeconds}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
`max-age=${cacheSeconds}, ` +
|
||||
`s-maxage=${cacheSeconds}, ` +
|
||||
`stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -188,7 +188,9 @@ describe("Test /api/gist", () => {
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.setHeader).toBeCalledWith(
|
||||
"Cache-Control",
|
||||
`max-age=${CONSTANTS.CARD_CACHE_SECONDS}, s-maxage=${CONSTANTS.CARD_CACHE_SECONDS}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
`max-age=${CONSTANTS.CARD_CACHE_SECONDS}, ` +
|
||||
`s-maxage=${CONSTANTS.CARD_CACHE_SECONDS}, ` +
|
||||
`stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user