Javascript Fetch API: Get Latest Version From Server (Non-Cached)

fetch(url, {cache: 'no-cache'})

Cache Options: https://developer.mozilla.org/en-US/docs/Web/API/Request/cache

  • default: browser will check cache for fresh content (no guarantee for latest from server)
  • no-store: always fetch from server, never store the result into cache
  • reload: get latest from server, store the result into cache
  • no-cache: If cache available, make conditional request to server to check if content has changed (if content has changed, download content and update cache)
  • force-cache: always use cache if available
  • only-if-cached: return if cahce is available, else return 504 Gateway timeout

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.