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

How do I use meta tags to control Prerender.io status codes?

Tell Prerender.io how to handle soft 404 pages and redirects so only valid pages stay in your cache.

TL;DR

Single-page applications typically return a 200 status code for every URL, even pages that do not exist or that redirect website visitors elsewhere. Prerender.io caches all of these by default, which leads to unnecessary cached pages and extra renders. You can fix this by adding prerender-status-code and prerender-header meta tags to your pages so Prerender.io handles them with the correct status code. 

Why this matters

Prerender.io decides whether to cache a page based on the HTTP status code it returns. Most single-page applications return 200 for every route, including URLs that should be 404 (page not found) or 301 (permanent redirect).

This creates two problems:

  • Soft 404 pages accumulate in your cache. Pages that do not exist get cached as 200, taking up space and counting toward your render usage.
  • Redirect pages get cached instead of forwarding. Pages that should redirect website visitors to another URL are cached as static pages instead.

Over time, these unnecessary pages build up and lead to extra charges on your render usage.

Step 1: Add a status code meta tag to soft 404 pages.

For pages that do not exist but return 200, add the following meta tag to the <head> section:

<meta name="prerender-status-code" content="404">

When Prerender.io sees this tag, it treats the page as a 404 instead of caching it as a valid page.

Step 2: Add status code and location meta tags to redirect pages.

For pages that should redirect website visitors to another URL, add both of these meta tags to the <head> section:

<meta name="prerender-status-code" content="301">

<meta name="prerender-header" content="Location: http://www.example.com">

Replace http://www.example.com with the actual destination URL. Prerender.io returns a 301 redirect to crawlers instead of caching the page.

Step 3: Use window.prerenderReady if meta tags are injected dynamically.

If your application injects meta tags after the initial page load, Prerender.io may capture the page before the tags are present. This can cause the status code to remain 200 even though you added the correct meta tag.

To prevent this, add the following script tag to the top of your <head> section:

<script> window.prerenderReady = false; </script>

This tells Prerender.io to wait before capturing the page. Once your page has fully loaded and the status code meta tags are in place, set the flag to true:

window.prerenderReady = true;

Prerender.io waits until window.prerenderReady is true before saving the HTML. This ensures the correct meta tags are included in the cached version.

ℹ️ You can use window.prerenderReady on any page, not just soft 404s and redirects. Set it to false in the <head>, then set it to true when the page is fully loaded to ensure Prerender.io captures the complete content.

Step 4: Verify your meta tags are working.

After adding the meta tags, confirm they are being picked up correctly:

  1. Log in to your Prerender.io dashboard and navigate to the cached pages for the affected URLs.
  2. Check whether the status codes reflect your meta tag values (404 for soft 404 pages, 301 for redirect pages).
  3. If pages still show 200, confirm the meta tags are present in the rendered HTML before window.prerenderReady is set to true.

 

✅ Your meta tags are working when soft 404 pages no longer appear as 200 in your cache and redirect pages return a 301 instead of cached content.

If pages are still cached as 200, see why is Prerender.io caching my 404 pages as 200? for additional troubleshooting steps.


Related articles


💬 Still need help? If your meta tags are not being picked up correctly and pages are still cached with the wrong status code, our support team can help you diagnose the issue. → Contact us at support@prerender.io

 

Was this article helpful?