refactor: improve cache control headers formatting (#4536)
Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
This commit is contained in:
1 parent
195e2fc72d
commit
f7920901b6
2 files changed
+6
-2
No files matched your search
+3
-1
@@ -31,7 +31,9 @@ const resolveCacheSeconds = ({ requested, def, min, max }) => {
|
|||||||
const setCacheHeaders = (res, cacheSeconds) => {
|
const setCacheHeaders = (res, cacheSeconds) => {
|
||||||
res.setHeader(
|
res.setHeader(
|
||||||
"Cache-Control",
|
"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}`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -188,7 +188,9 @@ describe("Test /api/gist", () => {
|
|||||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||||
expect(res.setHeader).toBeCalledWith(
|
expect(res.setHeader).toBeCalledWith(
|
||||||
"Cache-Control",
|
"Cache-Control",
|
||||||
`max-age=${CONSTANTS.TWO_DAY}, s-maxage=${CONSTANTS.TWO_DAY}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
`max-age=${CONSTANTS.TWO_DAY}, ` +
|
||||||
|
`s-maxage=${CONSTANTS.TWO_DAY}, ` +
|
||||||
|
`stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user