Bright Labs

How to test that your prerender setup works: fetch the page as a crawler and read the HTML

To check that your prerender setup works, request the page with a crawler's user agent and read the raw HTML that comes back. The prerender-node README says that with your browser's user agent set to Googlebot's, View Source should show "the static HTML version of the page". If you still see script tags, the README says the middleware isn't set up properly yet.

The catch: your normal browser visit won't show you any of this. The middleware checks the user agent string to decide whether a request comes from a crawler, so you have to send a crawler's user agent. Below are three ways to run the check, and what to look at first when it fails.

What the middleware does with a request

Before you test, it helps to know which gates a request passes through. The prerender-node README lists them:

So your test request has to get past every gate. Ask for a page, not an asset. Use a user agent the crawler list actually matches. If you set a whitelist or a blacklist, pick a path the list lets through. Miss any of these and your test tells you nothing about the prerender service.

Google describes the same pattern for dynamic rendering in general: it requires your web server to detect crawlers, for example by checking the user agent, and to route those requests to a rendering server.

Fetch the page as a crawler from the command line

This is the quickest check, with no browser in the way. curl's -A option lets you specify the User-Agent string to send to the HTTP server. If the string has spaces, the curl manual says to surround it with single or double quote marks. Without the option, curl uses its own user agent, curl/VERSION.

Example you write: compare a crawler response with a visitor response
PAGE_URL="<a page on your site>"

curl -A "Googlebot" "$PAGE_URL" > as-crawler.html
curl "$PAGE_URL" > as-visitor.html

# headers only, as a crawler
curl -I -A "Googlebot" "$PAGE_URL"

Swap "Googlebot" for whichever crawler you care about, as long as your middleware's list matches it. Then open both files side by side:

Check the status code even when the body looks right. Google's dynamic rendering guide warns that while you're setting up dynamic rendering, your site may produce error pages.

Check it in Chrome with a crawler user agent

If you'd rather stay in the browser, Prerender.io's verification guide gives steps for Chrome DevTools:

Here's the bit that's easy to miss: read View Source or the document's response body. Google's help page on rendered source says the plain source typically shows only the original page code returned to the browser. That original code is exactly what you want to inspect here.

Check what Google itself got

For the URL Inspection tool in Search Console and for the Rich Results Test, Google's help page says the HTML tab shows the rendered HTML for the page. For the Rich Results Test, the page must be available to Google without a login, and not blocked by robots.txt.

Keep in mind that this tab shows rendered HTML. Don't treat a complete page there as proof that the prerender service served it. Treat it as the final check after the curl test passes, not a replacement for it.

When the test fails: what to check first

If the crawler response still has script tags and no page text, work through these in order.

If you use RenderSwap, which we make at Bright Labs, run the same curl comparison against your site.

A short checklist to keep

Sources

Questions

Why does my page look fine in the browser when crawlers get an empty shell?

Because the middleware decides by user agent. prerender-node checks whether a request comes from a crawler by checking the user agent string against a default list of crawler user agents. To see what a crawler gets, send a crawler user agent with curl -A or with Chrome's Network Conditions panel.

Should the prerendered HTML still contain script tags?

No. The prerender-node README says View Source on a prerendered page should show the static HTML version of the page. If you still see script tags, it says the middleware isn't set up properly yet.

Can I test prerendering on localhost?

Yes, but the prerender server has to reach your server. The prerender-node README says that when testing locally you need to run the prerender server locally so that it has access to your server.

Is the URL Inspection tool enough to prove prerendering works?

It's a good final check, but don't lean on it alone. Google's help page says its HTML tab shows the rendered HTML for the page. Run the raw crawler request first, then confirm in Search Console.

Related