为什么每次请求都返回200,如何返回304?
app.get('/service', function (req, res) {
res.send([{
"id": "1001",
"name": "构建高性能Web站点",
"price": "56.10"
}, {
"id": "1002",
"name": "深入分析Java Web技术内幕",
"price": "51.80"
}, {
"id": "1003",
"name": "编写高质量代码:Web前端开发修炼之道",
"price": "36.80"
}, {
"id": "1004",
"name": "基于MVC的JavaScript Web富应用开发",
"price": "42.50"
}, {
"id": "1005",
"name": "RESTful Web Services Cookbook中文版",
"price": "44.30"
}]);
});
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
原来是开了 chrome 的disable cache...
推荐你用这个配置cache control
express-cache-control
没开disable cache的话可以看一下你的http请求报文呢。 cache-controll 或者expires 可以看到200 from cache的时间。以及last-modified值