Advanced Device Type Management
You can force Prerender to render pages with a specific device type, which will override the automatic device detection system.
Overview
Prerender.io offers a Mobile Optimized Rendering setting that allows you to render different versions of your site depending on whether the user is on a mobile device or desktop. To take advantage of this feature, you need to specify the device type when making a request to the Prerender service.
By adding the X-Prerender-Device-Type
header with the appropriate value (either Mobile or Desktop) when sending requests to https://service.prerender.io, you can control how pages are rendered for different devices.
How It Works
To use Mobile Optimized Rendering, follow these steps:
-
Enable the Mobile Optimized Rendering Setting:
-
Ensure that your Prerender.io account has the Mobile Optimized Rendering setting enabled. This can be done from your Advanced Settings Prerender dashboard.
-
-
Add the X-Prerender-Device-Type Header:
-
When making a request to Prerender.io, include the
X-Prerender-Device-Type
header with either the valueMobile
orDesktop
. -
Example:
-
For Mobile:
X-Prerender-Device-Type: Mobile
-
-
-
-
- For Desktop:
X-Prerender-Device-Type: Desktop
- For Desktop:
-
Note: This header is case-insensitive, so you can use "mobile," "desktop," or any variation (e.g., "MOBILE," "DESKTOP").
Key Takeaways
-
The
X-Prerender-Device-Type
header lets you specify whether the page should be rendered as mobile or desktop. -
This feature is available only if the Mobile Optimized Rendering setting is enabled in your Prerender dashboard.
-
The device type detection is case-insensitive, so it doesn't matter whether you use uppercase or lowercase letters in the header value.
Tips & Notes
-
Mobile-Optimized Pages: Mobile versions of your pages are often simplified or adjusted for smaller screens and faster load times. By using the
X-Prerender-Device-Type
header, you ensure that search engines and bots receive the appropriate version of your site. -
Testing: Always test your mobile and desktop versions to ensure that the appropriate rendering is taking place. You can do this by checking your rendered pages and making sure they match the device type you've set.
-
Performance Considerations: If your website has significantly different content or styling for mobile versus desktop users, using this setting will ensure that crawlers correctly index the mobile-friendly version of your site, which can positively affect your mobile SEO rankings.
-
Use in API Requests: The
X-Prerender-Device-Type
header can be used in both standard requests and API integrations with Prerender.io, providing flexibility across different types of workflows.
By following these guidelines, you can optimize your site for mobile devices and ensure search engines correctly index both your desktop and mobile pages. This ultimately helps improve your site's SEO and user experience across devices.