We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Response
1 parent 40e03ca commit c92a96dCopy full SHA for c92a96d
rest/getCachedAt.ts
@@ -0,0 +1,12 @@
1
+/** ServiceWorkerにcacheされた日時を得る
2
+ *
3
+ * cacheされたResponseでなければ`undefined`を返す
4
5
+ * @param res Response to check the chached date
6
+ * @return cached date (as UNIX timestamp) or `undefined`
7
+ */
8
+export const getCachedAt = (res: Response): number | undefined => {
9
+ const cachedAt = res.headers.get("x-serviceworker-cached");
10
+ if (!cachedAt) return;
11
+ return parseInt(cachedAt);
12
+};
rest/mod.ts
@@ -16,3 +16,4 @@ export * from "./error.ts";
16
export * from "./getCodeBlocks.ts";
17
export * from "./getCodeBlock.ts";
18
export * from "./uploadToGCS.ts";
19
+export * from "./getCachedAt.ts";
0 commit comments