我将Axios与React Native一起使用。为了处理缓存,我将标头设置如下:
await axios({
method: 'get',
url: someURL,
params: {
username: username,
},
headers: { 'cache-control': 'no-cache, no-store, max-age=0, must-revalidate'}
})
但是,当我打印response.config.headers
和response.headers
时,我得到了:
response.config.headers
Object {
"Accept": "application/json, text/plain, */*",
"cache-control": "no-cache, no-store, max-age=0, must-revalidate",
}
response.headers
Object {
"cache-control": "public, max-age=0",
"connection": "Keep-Alive",
"content-type": "application/json;charset=UTF-8",
"date": "Mon, 18 Nov 2019 12:33:05 GMT",
"expires": "0",
"keep-alive": "timeout=5, max=99",
"server": "Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.19",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-frame-options": "DENY",
"x-xss-protection": "1; mode=block",
}
这是完整的Axios代码:
await axios({
method: 'get',
url: someURL,
params: {
username: username,
},
headers: { 'cache-control': 'no-cache, no-store, max-age=0, must-revalidate'}
})
.then (function(response) {
console.log(response.config.headers);
console.log(response.headers);
})
.catch (function(error) {
console.log('SOMETHING WENT WRONG');
});
答案 0 :(得分:0)
根据我们的评论交流,这不是React Native的问题,而是您的Spring Boot服务器的问题。您可能想查看this question或查看Spring文档如何管理缓存。如果仍有问题,可以提出一个新问题。