動的な node.js Web サイトを作成しています。ブラウザにページを保存させたくありません。つまり、ユーザーがリロードをクリックするたびに、ページを最初からリロードしたいのです。現時点では、"Cache-Control":"no store" を送信しているにもかかわらず、ページがまだキャッシュされているように見えます。ここに私のサーバーがあります:
// requires node's http module
var http=require('http');
var url=require('url');
var fs=require('fs');
// creates a new httpServer instance
http.createServer(function (req, res) {
// this is the callback, or request handler for the httpServer
log('in server callback')
res.ins=res.write;
var parse=url.parse(req.url,true);
var path0=parse.pathname;
var mime=core.getMime(path0)
console.log(path0)
// respond to the browser, write some headers so the
// browser knows what type of content we are sending
var servePage=function(){
var path='./page'+path0+'.js'
console.log(path)
fs.exists(path,function(e){
if(e){
log('serving page')
var exp=require(path);
if(exp && exp.html){
var html=exp.html
}
else{
var html='bad file'
}
}
else{
console.log('no page to serve')
var exp=require('./page/pageHome.js')
var html=exp.html
}
res.writeHead(200, {'Content-Type': mime, 'Cache-Control': 'no store'});
res.ins(html);
res.end();
})
}
servePage()
}).listen(8080); // the server will listen on port 8080
また、「 http://mydomain.com/page?q=42 」などのランダムなクエリ文字列を使用してセルフ リンクを作成しようとしましたが、それでもキャッシュをバイパスしませんでした。私は何を間違っていますか?ありがとう!