我(初学者)尝试使用node.js和Express框架提供gzipped jpegs.我有/ public文件夹中的图像.我的代码看起来像:
// require the express module
var express = require('express');
var app = express();
app.use(express.logger());
//compress static content
app.use(express.compress());
// GET verbs
app.get('/', function(request, response) {
response.send('Hello World!');
});
// GET /public/*
app.use(express.static(__dirname + '/public'));
// Start the app on port 8080 if PORT not set
var port = process.env.PORT || 8080;
app.listen(port, function() {
console.log("Listening on " + port);
});
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?在Chrome调试器上,禁用缓存(确保HTTP响应代码为200),在响应中找不到content-encoding:gzip标头.
关于我缺少什么的任何线索?