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
It's a middleware to include 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 don't cache resources and ensure to serve the most fresh version.