Skip to content
  • There are no suggestions because the search field is empty.

Fastly Integration Guide

This guide aims to help you integrate Prerender with Fastly CDN. 

 

This guide will help you integrate Prerender with Fastly CDN, providing a seamless way to pre-render dynamic content and optimize your site's performance. By leveraging Fastly's powerful CDN capabilities, you can ensure that web crawlers like Googlebot see your fully-rendered pages, improving SEO and reducing the time it takes for your users to interact with your site. 

Important Note: This integration relies on Fastly’s VCL (Varnish Configuration Language) snippets to manage request handling and forward traffic to Prerender.

Integration Steps

Video guide:

Prerender token

The location of the Prerender token has changed. You can find it under the Security and Access menu under Prerender Token.

 

You can find the required source codes in the text guide below.

Text guide:

1. Set backend host for Prerender

You need to configure a backend in Fastly to forward requests to Prerender’s service. This step will ensure that all bot requests are routed to Prerender, which will then fetch the pre-rendered content.

Where to add:

  • Insert the following snippet in the init section of your Fastly VCL configuration.
  • Also add your unique service share key.

image(66)

image(65)

backend Prerender_Host {
.between_bytes_timeout = 10s;
.connect_timeout = 1s;
.dynamic = true;
.first_byte_timeout = 25s;
.host = "service.prerender.io";
.max_connections = 200;
.port = "443";
.share_key = "YOUR_SERVICE_ID";

.ssl = true;
.ssl_cert_hostname = "service.prerender.io";
.ssl_check_cert = always;
.ssl_sni_hostname = "service.prerender.io";

.probe = {
.dummy = true;
.initial = 5;
.request = "HEAD / HTTP/1.1" "Host: service.prerender.io" "Connection: close";
.threshold = 1;
.timeout = 2s;
.window = 5;
}
}

Important: Ensure that the first_byte_timeout is set to a higher value than your Rendering Timeout in the Prerender Dashboard (default is 20 seconds).

 

2. For forwarding bot requests to Prerender

Now, you need to route traffic from bots (like Googlebot and other crawlers) to Prerender. This step ensures that bots receive fully rendered HTML content.

Where to add:
  • Insert the following snippet in the subroutine and select the recv section.
  • Also, please add your token to the corresponding line from your Prerender.io Token from the Security and Access menu.image(60)
  if( req.http.User-Agent ~ "(?i)prerender"){
return(pass);
}
if( req.http.User-Agent ~ "(?i)googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|linkedinbot|embedly|showyoubot|outbrain|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp|ImgProxy| flipboard|tumblr|bitlybot|skype|nuzzel|discordbot|google|qwantify|pinterest|lighthouse|telegrambot|Perplexity|OAI-SearchBot|ChatGPT|GPTBot|ClaudeBot|Amazonbot" && req.url.ext !~ "(?i)js|css|xml|txt|less|png|jpg|jpeg|gif|pdf|doc|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|woff|ttf|svg|webmanifest" ) {

set req.backend = Prerender_Host;



set req.http.user-agent = req.http.user-agent;

set req.url = "/https://" req.http.host req.url;



set req.http.x-prerender-token = "YOUR PRERENDER TOKEN";
set req.http.int-type = "Fastly";

return(pass);

}

 

3. Change the cache key

To avoid caching issues, modify the cache key to ensure that Fastly treats requests from different user agents separately. 

Where to add:

  • Go to your request settings, then at the very bottom add a new Request setting.

image(62)

  • At the Advanced Setting part modify the Cache Key to the following
    image(73)
req.url, req.http.host, req.http.User-Agent

 


 

Verify Your Installation

After integration, it’s important to verify that everything is working as expected. We’ve provided an easy-to-follow guide to help you test your setup and confirm that Prerender is functioning properly.

Or, test with curl command with a custom User-Agent header:

curl -v -A googlebot www.yourpage.com/

 

Is the Prerender integration working on other pages?

Test if the Prerender integration works on the other pages based on this guide: Verify the integration

If you don't see the Prerender headers / IDs, then the Integration is not working, which might be why the other URL is not cached. 

 

Getting an Error?

If you see the message "Prerender Integration Not Detected," you can refer to the troubleshooting guide here to help resolve the issue.

 

Expert Assistance

For those who need additional help or want to ensure a smooth and secure launch, we offer a specialized package:

Kickstart Package

Price: $800 (one-time payment)

This one-time package empowers you with expert setup and configuration, ensuring a smooth and secure launch.

Features:

  • Three setup and configuration sessions with our experts
  • Onboarding assistance
  • Security assessment

To learn more about this package or to purchase, visit the Packages section under the Billing menu in your Prerender dashboard. 


 

Get Support

If you're still encountering issues after implementing Prerender:

  • Review your implementation against our documentation
  • Contact our support team:

To help us resolve your issue as quickly as possible, please gather and include any relevant information, such as:

  • Error messages you're seeing
  • Steps you've already taken to troubleshoot
  • Screenshots or screen recordings (if applicable)

Providing these details up front will help our team diagnose the problem more efficiently and get you back on track faster.

 

Related Articles: