android - React Native + Expo 获取缓存控制
问题描述
我正在使用与 redux 集成的 react native expo 构建 android 应用程序。使用 fetch 方法调用 API,但始终显示缓存的结果。Cache-Control 标头不与请求一起使用。我尝试了两种类型的标题定义;
var myHeaders = new Headers();
myHeaders.set('Accept', 'application/json');
myHeaders.set('Content-Type', 'application/json');
myHeaders.set('Cache-Control', 'no-cache');
fetch(
"http://192.168.1.71:3000/", {
method: 'GET',
headers: myHeaders
})
.then(response => console.log(response)).catch(err=>console.log(err));
和
fetch("http://192.168.1.71:3000/",{
"method": "POST",
headers: {
'cache-control': 'no-cache',
'Accept': 'application/json',
'Content-Type': 'application/json; charset=utf-8',
}, cache: "no-cache",})
.then(response => console.log(response))
.catch(err=>console.log(err));
但每次服务器中的 request.headers 显示:
{ accept: 'application/json',
'content-type': 'application/json; charset=utf-8',
host: '192.168.1.71:3000',
connection: 'Keep-Alive',
'accept-encoding': 'gzip',
'user-agent': 'okhttp/3.12.1' }
服务器端没有缓存控制。难道我做错了什么?
解决方案
推荐阅读
- powershell - 使用 Graph API 从 MS-Exchange 获取邮件
- spring-boot - 更新spring boot后出现jackson-databind序列化错误
- sql - 从一个文件运行不同的 pl/sql 脚本
- c# - 如何使用 Microsoft Graph 在电子邮件正文中嵌入图像
- excel - 使用基于 Interior.Color 的合并单元格清除单元格范围的内容
- python - 重置为 0 的多维 Numpy 数组的累积和
- node.js - doc和ppt文件中的水印节点库
- c# - 重新加载页面时,Blazor 将基本过滤器数据保存到浏览器
- list - 如何在另一个类中使用创建的列表?
- sql - 使用 Hive 窗口框架组合记录