prerendercloud-ruby
Rack middleware for pre-rendering JavaScript single page apps with Headless-Render-API.com (formerly named prerender.cloud from 2016 - 2022)
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:
- potential cloaking penalties
- 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']