1.0.1 • Published 8 years ago

bedrock-prerender v1.0.1

Weekly downloads
9
License
-
Repository
github
Last release
8 years ago

bedrock-prerender

Build Status

This is a bedrock-based library that provides a PhantomJS rendering engine that can be used to render HTML from AngularJS pages. This allows bots that do not execute Javascript on pages to parse and index pages properly.

The site must be minified/optimized for the rending engine to function properly.

Pages connected with defined routes are rendered to HTML the first time they are requested and added to a Redis cache. Subsequent requests for the same route will be served directly from the Redis cache until the specified time to live (TTL) has expired. Only bot request containing a User-Agent header in the list of defined crawlerUserAgents will be rendered. All other requests will be handled normally.

Quick Examples

var config = require('bedrock').config;

// Default TTL (sec) for all URLs added to cache
config.prerender.cache.ttl = 10000; // default: 300

// Prerending is enabled only on defined routes.
// An optional route specific `cacheTtl` (sec) may be specified.
config.prerender.routes = {
  '/about': {cacheTtl: 10000},
  '/i/*': {}
};

Simulate a bot request for testing

curl -k -A twitterbot https://bedrock.dev:18443/about
1.0.1

8 years ago

1.0.0

8 years ago