Optimize your BotRender integration for maximum SEO performance, faster indexing, and better search engine visibility.
Serve cached HTML to bots; on cache miss, return 404 quickly and queue a render. Optionally fall back to SPA so first crawl still gets content.
Synchronously render on bot requests. Higher latency and risk of timeouts; use with caution.
Return proper 404 status for missing pages
<meta name="prerender-status-code" content="404">
Handle permanent redirects correctly
<meta name="prerender-status-code" content="301"> <meta name="prerender-header" content="Location: https://new-url.com">
Set status codes programmatically based on content
// JavaScript example
if (pageNotFound) {
document.head.innerHTML += '<meta name="prerender-status-code" content="404">';
}Control when BotRender considers the page fully loaded
<script>
// Initially set to false
window.prerenderReady = false;
// Set to true when all content is loaded
Promise.all([
loadCriticalData(),
loadAsyncComponents()
]).then(() => {
window.prerenderReady = true;
});
</script>Delay rendering until critical API requests complete
async function waitForData() {
const data = await fetch('/api/critical-data');
const result = await data.json();
// Render content with data
renderComponent(result);
// Signal ready for prerendering
window.prerenderReady = true;
}Set appropriate cache times based on content update frequency
Trigger recaching when content changes
// Recache when content updates
const recacheUrl = async (url) => {
await fetch('https://api.botrender.com/recache', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({ url })
});
};
// Trigger after content update
await updateArticle(articleId);
await recacheUrl(`/articles/${articleId}`);Include all major search engines, social platforms, and AI crawlers
Use patterns that catch new bot variants
const isBot = (userAgent) => {
const botPattern = /(googlebot|bingbot|slurp|duckduckbot|baiduspider|yandexbot|facebookexternalhit|twitterbot|linkedinbot|pinterestbot|chatgpt-user|gptbot|claude-web|perplexitybot|ahrefsbot|semrushbot)/i;
return botPattern.test(userAgent);
};Prioritize loading of essential content
Reduce JavaScript execution time for faster rendering
// Optimize heavy computations
const optimizeRendering = () => {
// Use requestIdleCallback for non-critical work
requestIdleCallback(() => {
performHeavyCalculations();
});
// Critical rendering path
renderEssentialContent();
window.prerenderReady = true;
};Hide cookie banners from search engine bots
// Detect if request is from a crawler
const isCrawler = () => {
const userAgent = navigator.userAgent || '';
return /bot|crawler|spider|crawling/i.test(userAgent);
};
// Only show cookie banner to real users
if (!isCrawler()) {
showCookieBanner();
}Handle cookie banners at the server level
// Express.js example
app.use((req, res, next) => {
const isBot = /bot|crawler|spider/i.test(req.get('User-Agent'));
res.locals.showCookieBanner = !isBot;
next();
});Generate schema markup based on page content
const generateSchema = (pageData) => {
const schema = {
"@context": "https://schema.org",
"@type": "Article",
"headline": pageData.title,
"description": pageData.description,
"author": pageData.author,
"datePublished": pageData.publishDate
};
const script = document.createElement('script');
script.type = 'application/ld+json';
script.textContent = JSON.stringify(schema);
document.head.appendChild(script);
};Ensure schema markup is valid before rendering
Start implementing these best practices today and see immediate improvements in your SEO performance and search engine visibility.