Nginx

note

Double check the user agents whitelisted for every deployment, since you may not need all of them, or you might want to add some

Every deployment can also be used as a Edge Cache API. You can simply forward requests to us when you detect a bot in a user agent.

This is the recommended way to deploy.

Seeing a WRCacheHit header with a value of 1 indicates the cache was hit - but you can safely forward any requests since we will simply fetch origin if it's not in the cache. If it's from a crawler that doesn't support JS we'll pre-render it, if the the client does support JS it'll be rendered on the fly.

Nginx

# Change YOUR_DEPLOYMENT to your deployment id
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
location / {
try_files $uri @webrender;
}
location @webrender {
set $webrender 0;
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp") {
set $webrender 1;
}
if ($args ~ "_escaped_fragment_") {
set $webrender 1;
}
if ($uri ~* "\.(js|css|xml|less|png|jpg|jpeg|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif|wav|mov|psd|ai|xls|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent|ttf|woff|svg|eot)") {
set $webrender 0;
}
#resolve using Google's DNS server to force DNS resolution and prevent caching of IPs
resolver 8.8.8.8;
if ($webrender = 1) {
#Force DNS resolution
set $webrender "YOUR_DEPLOYMENT.webrender.io";
rewrite .* /$scheme://$host$request_uri? break;
proxy_pass http://$webrender;
}
if ($webrender = 0) {
rewrite .* /index.html break;
}
}
}