Cache Control
The cache option controls how fetch interacts with the browser HTTP cache.
The cache option controls how fetch interacts with the browser HTTP cache.
// Use cache if fresh, else network
await fetch(url, { cache: "default" });
// Always network, update cache
await fetch(url, { cache: "reload" });
// Always network, never cache
await fetch(url, { cache: "no-store" });
// Use cache even if stale
await fetch(url, { cache: "force-cache" });
// Use cache if available, else 504
await fetch(url, { cache: "only-if-cached", mode: "same-origin" });
cache: "reload" busts the cache for a single request without clearing the entire cache.
More in JavaScript