No cache

禁用浏览器缓存

描述

修改响应以禁用浏览器缓存。Lume 在 --serve 模式下使用它,以确保交付任何文件的最新版本。

安装

此中间件必须与 Lume 的 HTTP 服务器 一起使用。创建一个入口点文件(例如,serve.ts),包含以下代码:

import Server from "lume/core/server.ts";
import noCache from "lume/middlewares/no_cache.ts";

const server = new Server();

server.use(noCache());

server.start();

Important

除非你有充分的理由,否则不要在生产环境中使用此中间件。禁用缓存会使你的网站变慢。

本地开发

--serve 模式下,Lume 默认使用此中间件。