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