const express = require('express');
const path = require('path');
const app = express();
// 设置静态文件目录
app.use(express.static(path.join(__dirname, 'public'), {
maxAge: '1d', // 设置缓存的最大时间
etag: false, // 禁用 ETag
lastModified: false, // 禁用 Last-Modified
setHeaders: function (res, path) {
res.setHeader('Cache-Control', 'public, max-age=86400'); // 设置 Cache-Control 标头
}
}));
app.listen(3000, () => {
console.log('Server started on port 3000');
});