sportihome-prerender-filesystem-cache
v1.0.0
Published
prerender.io plugin for caching in file system (based on https://github.com/suhanovv/prerender-file-cache)
Downloads
4
Readme
prerender-filesystem-cache
This is a plugin for prerender(.io) providing caching in the file system. It is a fork of https://github.com/suhanovv/prerender-file-cache, focussing on improved URI parsing, platform-independency and providing test coverage.
Version 2.0.0
has been tested to work with prerender
version 5.4.x
.
Requires node >= 4.0
Status
How it works
This plugin will store all prerendered pages into a filesystem hierarchy. For example:
- url http://domain.lo/?escaped_fragment=/en/about - will be saved in
CACHE_ROOT_DIR/en/about/perender.cache.html
- url http://domain.lo/en/about?escaped_fragment= - will be saved in
CACHE_ROOT_DIR/en/about/perender.cache.html
- url http://domain.lo/?escaped_fragment=/en/main/path/blah - will be saved
in
CACHE_ROOT_DIR/en/main/path/blah/perender.cache.html
- url http://domain.lo/en/main/path/blah?escaped_fragment= - will be saved
in
CACHE_ROOT_DIR/en/main/path/blah/perender.cache.html
How to use
The package is available on npm. Thus, in your local prerender project simply run:
$ npm install prerender-filesystem-cache --save
Then in the server.js
that initializes prerender:
server.use(require('prerender-filesystem-cache'));
Configuration
Optionally, define some env variables:
export CACHE_ROOT_DIR=/your/directory/for/cache
export CACHE_LIVE_TIME=10000 (in seconds)
CACHE_ROOT_DIR
defaults toos.tmpdir()/prerender-cache
CACHE_LIVE_TIME
defaults to 3600 (1 hour)