express rest api默认没有缓存吗?

为什么每次请求都返回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"
    }]);
});
阅读 3.9k
3 个回答

原来是开了 chrome 的disable cache...

没开disable cache的话可以看一下你的http请求报文呢。 cache-controll 或者expires 可以看到200 from cache的时间。以及last-modified值

推荐问题