save-static
Save Express responses to a static directory for disk caching
Use save-static as a callback on Express Application.render()
or Response.render()
and it will:
- Write the rendered response body (HTML) to a file on disk
- after sending the response to the client (to avoid slow responses)
Then subsequent requests can be served from disk using:
Use in conjunction with serve-static-x for caching and re-caching files to disk.
Install
$ npm install --save save-static
Usage
// be sure to require itvar SaveStatic = ; // initialize with the root path for saving to diskvar staticPath = __dirname + '/static'; // <= for examplevar saveStatic = staticPath; // ... // here's a sample Express routeapp
License
ISC © Buster Collings