1. Set up Fastly VCL snippets in Magento
Log in as an admin user on your Magento store and navigate to Store → Configuration → Advanced → System → Full Page Cache. Confirm that the Caching Application is set to Fastly CDN, then enter your Fastly Service ID and API token.
Open the Custom VCL Snippets section. You need to add two snippets: one to define the Similar AI backend, and one to route requests to it.
Backend definition (type: init, priority: 100)
This snippet defines a new Fastly backend that points to your Similar AI proxy host. Replace <<client_com>> with your domain name (e.g. example if your site is example.com).
backend F_similarai_proxy {
.host = "<<client_com>>.page.similar.ai";
.port = "80";
.probe = {
.dummy = false;
.request = "HEAD / HTTP/1.1" "Host: storage.googleapis.com" "Connection: close";
.expected_response = 200;
.interval = 60s;
.timeout = 2s;
.window = 5;
.initial = 4;
.threshold = 4;
}
}Request routing (type: recv, priority: 100)
This snippet checks the URL path and routes matching requests to the Similar AI backend. The /s/ prefix is the subfolder agreed upon during onboarding. F_Host_1 is your origin host in Fastly.
if (req.url.path ~ "/s/") {
set req.http.Host = "<<client_com>>.page.similar.ai";
set req.backend = F_similarai_proxy;
} else {
set req.backend = F_Host_1;
}After adding both snippets, go to the Automatic Upload & Service Activation section and click Upload VCL to Fastly to push the configuration live.
2. Fix backend ordering in Fastly admin
Fastly inserts any defined backends after VCL snippets in the generated configuration. This means the snippets added from Magento admin will not route correctly on their own. The fix is to attach an always-false condition to the default backend so Fastly does not override your routing logic.
Step A: Create a false condition
Log in to the Fastly Admin dashboard. Go to Conditions in the left nav, click Create Condition, and add a condition that always evaluates to false:
req.url == "1"
Step B: Attach the condition to your origin
Go to Origins/Hosts in the left nav, select your origin host, and attach the always-false condition you created above. This prevents Fastly from inserting a default backend assignment that would override your VCL snippet routing.
Final generated VCL
After applying both the snippets and the condition workaround, the generated VCL will look like this. Notice the false condition at the bottom prevents the default backend from taking effect:
# Snippet magentomodule_proxypage : 100
if (req.url.path ~ "/s/") {
set req.http.Host = "client_com.page.similar.ai";
set req.backend = F_similarai_proxy;
} else {
set req.backend = F_Host_1;
}
# default conditions
if (!req.http.Fastly-SSL) {
error 801 "Force SSL";
}
# Request Condition: host Prio: 10
if( req.url == "1" ) {
set req.backend = F_Host_1;
}The req.url == "1" condition never matches a real request, so the default backend assignment is effectively disabled.
Frequently asked questions
Why do I need a reverse proxy to serve Similar AI pages on Magento?
Similar AI's New Pages Agent generates and hosts new category, landing, and topic pages on its own infrastructure. A Fastly reverse proxy lets your Magento storefront serve those pages transparently under your own domain, preserving SEO authority and keeping URLs consistent for shoppers.
What Fastly components do I need to configure for this integration?
You will need to define a custom Fastly backend pointing to Similar AI's origin, then add VCL recv snippets to route matching URL patterns to that backend. The guide also covers condition workarounds specific to Magento's default Fastly module, which can conflict with custom backend routing.
Will adding a Similar AI backend in Fastly affect my existing Magento pages?
No, the VCL conditions are written to match only the URL paths that the New Pages Agent manages, leaving all standard Magento routes unaffected. You can scope these conditions tightly by path prefix or regex to avoid any overlap with existing product or category pages.
How do I handle Magento's built-in Fastly module when adding custom VCL snippets?
Magento's Fastly module applies its own default conditions and recv logic that can override custom snippets if priority values clash. The guide walks through setting the correct snippet priority order and any condition workarounds needed to ensure Similar AI routing takes precedence for the targeted paths.
Do Similar AI pages served via Fastly still get cached correctly?
Yes, Similar AI pages return standard cache-control headers that Fastly respects, so they are cached at the edge just like your other content. You can also configure a separate cache TTL for the Similar AI backend within your VCL to align caching behavior with how frequently the Content Agent updates those pages.
Ready to add new pages to your Magento store?
Similar AI creates SEO-optimized pages and serves them through your existing domain using a simple reverse proxy setup. Get started with a demo.