incremental-regeneration
v0.3.0
Published
![npm](https://img.shields.io/npm/v/incremental-regeneration?color=green&logo=npm)
Downloads
6
Readme
incremental-regeneration
About
This middleware adds so-called Incremental Static Regeneration to your server.
Installation
npm i incremental-regeneration
Basic usage
import isrMiddleware from 'incremental-regeneration';
// define your server
const server = ...
const myFunctionThatRendersPage = (req, res) => void;
server.use(isrMiddleware({
middleware: myFunctionThatRendersPage,
revalidateTime: 10
}))
//
Options
revalidateTime
(in seconds): time boundary after which the resource would be regenerated
middleware
: function that matches type (req: http.ClientRequest, res: http.ServerResponse) => void. This function is expected to render a response and write it to res param.