Baseline Widely available *
Request
ì¸í°íì´ì¤ì cache
ì½ê¸° ì ì© ìì±ìë ìì²ì ìºì 모ëê° í¬í¨ëì´ ììµëë¤. ìì²ì´ ë¸ë¼ì°ì ì HTTP ìºì±ê³¼ ìí¸ ìì©íë ë°©ìì ì ì´í©ëë¤.
RequestCache
ê°ì
ëë¤. ì¬ì© ê°ë¥í ê°ì ë¤ìê³¼ ê°ìµëë¤.
default
â ë¸ë¼ì°ì ë HTTP ìºììì ì¼ì¹íë ìì²ì ì°¾ìµëë¤.
no-store
- ë¸ë¼ì°ì ë ìºì를 먼ì ì´í´ë³´ì§ ìê³ ì격 ìë²ìì 리ìì¤ë¥¼ ê°ì ¸ì¤ë©°, ë¤ì´ë¡ëë 리ìì¤ë¡ ìºì를 ì
ë°ì´í¸íì§ ììµëë¤.
reload
- ë¸ë¼ì°ì ë ìºì를 먼ì ì´í´ë³´ì§ ìê³ ì격 ìë²ìì 리ìì¤ë¥¼ ê°ì ¸ì¤ë©°, ê·¸ ë¤ìì¼ë¡ ë¤ì´ë¡ëë 리ìì¤ë¡ ìºì를 ì
ë°ì´í¸í©ëë¤.
no-cache
- ë¸ë¼ì°ì ë HTTP ìºììì ì¼ì¹íë ìì²ì ì°¾ìµëë¤.
force-cache
- ë¸ë¼ì°ì ë HTTP ìºììì ì¼ì¹íë ìì²ì ì°¾ìµëë¤.
only-if-cached
â ë¸ë¼ì°ì ë HTTP ìºììì ì¼ì¹íë ìì²ì ì°¾ìµëë¤.
"only-if-cached"
모ëë ìì² mode
ê° "same-origin"
ì¸ ê²½ì°ìë§ ì¬ì©í ì ììµëë¤. ìºìë 리ë¤ì´ë ì
ì ìì²ì redirect
ìì±ì´ "follow"
ì´ê³ 리ë¤ì´ë ì
ì´ "same-origin"
모ë를 ìë°íì§ ìë ê²½ì°ìë§ íì©ë©ëë¤.
// ìºì를 ìì í ì°íí기 ìí´ ìºì ë²ì¤í
기ë¥ì´ ìë 리ìì¤ë¥¼ ë¤ì´ë¡ëí©ëë¤.
fetch("some.json", { cache: "no-store" }).then((response) => {
/* ìëµ ì¬ì© */
});
// ìºì ë²ì¤í
기ë¥ì ì¬ì©íì¬ ë¦¬ìì¤ë¥¼ ë¤ì´ë¡ëíì§ë§, ë¤ì´ë¡ëë 리ìì¤ë¡ HTTP ìºì를 ì
ë°ì´í¸í©ëë¤.
fetch("some.json", { cache: "reload" }).then((response) => {
/* ìëµ ì¬ì© */
});
// ì¬ë°ë¥¸ ETagì Date í¤ë를 ì ì¡íê³ If-Modified-Sinceì If-None-Match ìì² í¤ë를 ì ì íê² ì²ë¦¬íë ì ëë¡ êµ¬ì±ë ìë²ë¥¼ ë¤ë£° ë ìºì ë²ì¤í
ì´ ìë 리ìì¤ë¥¼ ë¤ì´ë¡ëíë©´ ì í¨ì± ê²ì¬ì ìì¡´íì¬ ìë¡ì´ ìëµì ë³´ì¥í ì ììµëë¤.
fetch("some.json", { cache: "no-cache" }).then((response) => {
/* ìëµ ì¬ì© */
});
// ê²½ì ì±ì ì¼ëì ë 리ìì¤ë¥¼ ë¤ì´ë¡ëí©ëë¤! ê°ë¥í ë§ì ëìíì ì ì½í기 ìí´ ì¤ëëìì§ë§ ìºìë ìëµì ì í¸í©ëë¤.
fetch("some.json", { cache: "force-cache" }).then((response) => {
/* ìëµ ì¬ì© */
});
// í´ë¼ì´ì¸í¸ ìì¤ìì stale-while-revalidateë¡ ì ì§ë©ëë¤.
// ì¤ëë ìëµì´ë¼ë ìºìë ìëµì ì í¸íì§ë§, ë무 ì¤ëë ê²½ì° ì
ë°ì´í¸í©ëë¤.
// ë ëì ë©ëª¨ë¦¬ ì 리를 ìí´ AbortControllerì signal를 ì¬ì©í©ëë¤.
// ì¤ì ë¡ ì´ê²ì ê°ì ë³ê²½í´ì¼ íë¯ë¡ 컨í¸ë¡¤ë¬ì ëí ê²½ë¡ì 참조를 ì·¨íë í¨ìê° ë ê²ì
ëë¤.
let controller = new AbortController();
fetch("some.json", {
cache: "only-if-cached",
mode: "same-origin",
signal: controller.signal,
})
.catch((e) =>
e instanceof TypeError && e.message === "Failed to fetch"
? { status: 504 } // í¬ë¡¬ììì í´ê²° ë°©ë²: TypeErrorë¡ ì¤í¨
: Promise.reject(e),
)
.then((res) => {
if (res.status === 504) {
controller.abort();
controller = new AbortController();
return fetch("some.json", {
cache: "force-cache",
mode: "same-origin",
signal: controller.signal,
});
}
const date = res.headers.get("date"),
dt = date ? new Date(date).getTime() : 0;
if (dt < Date.now() - 86_400_000) {
// 24ìê°ì´ ì§ë ê²½ì°
controller.abort();
controller = new AbortController();
return fetch("some.json", {
cache: "reload",
mode: "same-origin",
signal: controller.signal,
});
}
// 기í ê°ë¥í ì¡°ê±´
if (dt < Date.now() - 300_000)
// 5ë¶ ì´ì ì§ë ê²½ì°
fetch("some.json", { cache: "no-cache", mode: "same-origin" }); // ì·¨ì í¹ì ë°í ê°ì´ ììµëë¤.
return res;
})
.then((response) => {
/* (ìë§ë ì¤ëë) ìëµ ì¬ì© */
})
.catch((error) => {
/* AbortError/DOMError í¹ì TypeErrorì¼ ì ììµëë¤. */
});
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4