如何刷新HTTP请求缓存?
当前状态
为刷新页面缓存存在许多答案
- ,但没有JavaScript发出的请求的“缓存”
- 问题
缓存:false
ajax请求 - set
expires
在服务器端
目标状态
下,但是有一种方法可以在客户端进行以下任一项操作?
- 刷新页面没有(页面缓存和请求缓存);实际上,CMD+Shift+R Reload在Edge(MAC OS)上实现此目的,
- 使AJAX请求不仅检索新数据(通过新的时间戳),而且还使用此数据覆盖原始请求缓存。
示例:page /names
加载之后,JavaScript get /api/names?id =< id>
; ajax方法将获得/api/names?id =< id>& _ _ =< timestamp>
,但这不会刷新/api/code>
目的
使用缓存来提高负载速度,同时还可以保留用户检索更新数据的灵活性。
Current state
Many answers exist for
- Refresh page cache but not the javascript-issued requests' cache
- Issue
cache: false
ajax request - Set
Expires
header at server-side
Goal state
However, is there a way to do either of the following at client-side?
- Refresh the page without (page cache AND requests cache); in fact, the CMD+SHIFT+R reload achieves this purpose on Edge(Mac OS)
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论