fetch 相比于 xhr

Fetch 功能优势

  1. Service Worker 环境里也能用,相比 xhr 只能运行在渲染进程内
  2. 同源请求也可以自定义不带 cookie,某些服务不需要 cookie 场景下能少些流量
  3. 可自定义重定向场景,xhr 只能 follow
  4. 自由度更高的 cache 配置
  5. 可自定义 referrer

fetch 相比于 xhr
http://blog.climbed.online/2023/11/24/Web -- Knowledge is infinite/前端/Web/fetch相比xhr/
作者
Z.K.
发布于
2023年11月24日
许可协议