Ruby Rack middleware middleware for server-side rendering JavaScript-rendered pages with https://www.prerender.cloud
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
Gemfile
Gemfile.lock
LICENSE
Makefile
README.md
Rakefile
prerendercloud.gemspec
rack_sample_app.rb

README.md

image

prerendercloud-ruby

Rack middleware for server-side rendering (prerendering) JavaScript web pages/apps (single page apps or SPA) with https://www.prerender.cloud/

Rails Usage

Gemfile

gem 'prerendercloud'

config/environment/production.rb

config.middleware.use Rack::Prerendercloud
# either hard code your secret token:
# config.middleware.use Rack::Prerendercloud, prerender_token: 'YOUR_TOKEN'
# or set the PRERENDER_TOKEN environment variable

Bots only

We don't recommend this setting due to:

  1. potential cloaking penalties
  2. missing out on performance gains of prerendering all traffic

but it's here if you want it:

config.middleware.use Rack::Prerendercloud, bots_only: true

Blacklist

Prevent certain paths from being prerendered (e.g. JSON API endpoints)

Pass an array of Regexps or Strings.

config.middleware.use Rack::Prerender, blacklist: [/^\/api/, '/housing_prices.json']

Whitelist

Only allow certain paths to be prerendered

Pass an array of Regexps or Strings.

config.middleware.use Rack::Prerender, whitelist: [/^\/users/, '/ips-v4']