Expires
Middleware to add the Expires header to HTTP responses
Options
- defaultDuration number
The default duration for unknown types
Default:604800000- durations record
List of types with the cache duration
Default:{ "text/html": 0, "application/json": 0, "application/xml": 0, "application/atom+xml": 3600000, "application/rdf+xml": 3600000, "application/rss+xml": 3600000 }
Description
Middleware to set the Expires header in the response for better caching.
Installation
This middeware must be used with the Lume's HTTP Server. To use it in production, you need a host running a Deno server, like Deno Deploy.
Create an entry point file (for example, serve.ts) with the following code:
import Server from "lume/core/server.ts";
import expires from "lume/middlewares/expires.ts";
const server = new Server();
server.use(expires());
server.start();
Local development
It's not recommended to use this middleware in local development because the whole point of a local server is to not cache resources and to ensure serving the most fresh version of your content.