Chr*_*ith 3 caching http-headers node.js express hapijs
如何将hapi中的缓存控制头设置为"no-cache","no-store","must-revalidate"?
在快递中,我能够做到以下几点:
res.header('Cache-Control', 'no-cache, no-store, must-revalidate');
我目前在hapi中有以下内容,但我认为它可能不正确:
function(request, reply){
var response = reply();
response.header('Cache-Control', 'no-cache');
response.header('Cache-Control', 'no-store');
response.header('Cache-Control', 'must-revalidate'
}
Run Code Online (Sandbox Code Playgroud)
是否可以在hapi中执行此操作?
function(request, reply){
var response = reply();
response.header('Cache-Control', 'no-cache, no-store, must-revalidate');
}
Run Code Online (Sandbox Code Playgroud)
是的,你可以做到.string('no-cache, no-store, must-revalidate'
)只是标题的单个值,因此将其设置为任何标题.通过调用响应对象header()
上的方法.
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply('ok').header('Cache-Control', 'no-cache, no-store, must-revalidate');
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1493 次 |
最近记录: |