如何刷新HTTP请求缓存?

发布于 2025-02-06 14:20:57 字数 601 浏览 2 评论 0原文

当前状态

为刷新页面缓存存在许多答案

  1. ,但没有JavaScript发出的请求的“缓存”
  2. 问题缓存:false ajax请求
  3. set expires在服务器端

目标状态

下,但是有一种方法可以在客户端进行以下任一项操作?

  1. 刷新页面没有(页面缓存和请求缓存);实际上,CMD+Shift+R Reload在Edge(MAC OS)上实现此目的,
  2. 使AJAX请求不仅检索新数据(通过新的时间戳),而且还使用此数据覆盖原始请求缓存。

示例:page /names加载之后,JavaScript get /api/names?id =< id>; ajax方法将获得/api/names?id =< id>& _ _ =< timestamp>,但这不会刷新/api/code>

目的

使用缓存来提高负载速度,同时还可以保留用户检索更新数据的灵活性。

Current state

Many answers exist for

  1. Refresh page cache but not the javascript-issued requests' cache
  2. Issue cache: false ajax request
  3. Set Expires header at server-side

Goal state

However, is there a way to do either of the following at client-side?

  1. Refresh the page without (page cache AND requests cache); in fact, the CMD+SHIFT+R reload achieves this purpose on Edge(Mac OS)
  2. Make an ajax request not only retrieve new data(by new timestamp) but also use this data to overwrite the original request cache.

Example: after page /names loads, Javascript GET /api/names?id=<id>; ajax method would GET /api/names?id=<id>&_=<timestamp>, but this does not refresh cache for/api/names

Purpose

Use cache to increase load speed, while also preserving users' flexibility to retrieve updated data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文