0.3.0 • Published 4 years ago

incremental-regeneration v0.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

incremental-regeneration

npm

About

This middleware adds so-called Incremental Static Regeneration to your server.

More on ISR

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.