码迷,mamicode.com
首页 > 其他好文 > 详细

node express 304 avoid

时间:2016-04-21 13:21:55      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:

method 1

Why do I need this? The right answer is: I don’t need that trick!

The example below is just to show how to use routes to intercept requests to a static file.

Put router before static.

app.use(app.router);
app.use(express.static(__dirname + ‘/static‘));

Add ‘/*’ handler (don’t forget to call next())

app.get(‘/*‘, function(req, res, next){ 
  res.setHeader(‘Last-Modified‘, (new Date()).toUTCString());
  next(); 
});


method 2()

app.use(function(req, res, next){
res.header("Cache-Control", "no-cache, no-store, must-revalidate");
res.header("Pragma", "no-cache");
res.header("Expires", 0);
next();
});

 

method 3

Easiest solution:

app.disable(‘etag‘);

node express 304 avoid

标签:

原文地址:http://www.cnblogs.com/voctrals/p/5416367.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!