Skip to main content

Viewport & Device-Aware Rendering

PRISM can render pages with different viewport dimensions based on the requesting device class. This ensures that mobile bots (like Googlebot-Mobile) receive mobile-rendered content while desktop bots receive the desktop layout.

Configuration

[render.viewport]
enabled = true
mobile_width = 412
mobile_height = 915
desktop_width = 1920
desktop_height = 1080

When enabled = false (the default), all renders use a fixed 1920x1080 desktop viewport.

Device Detection

PRISM classifies the User-Agent into two device classes based on these case-insensitive indicators:

Device ClassUser-Agent Indicators
MobileMobile, Android, iPhone, iPad, Googlebot-Mobile, smartphone
DesktopEverything else (default)

Examples:

User-AgentClass
Googlebot/2.1 (+http://www.google.com/bot.html)Desktop
Googlebot-MobileMobile
Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)Mobile
GPTBot/1.0Desktop
ClaudeBot/1.0Desktop

Cache Key Separation

When viewport-aware rendering is enabled, the cache key includes a device class suffix:

  • Desktop: https://example.com/products::desktop
  • Mobile: https://example.com/products::mobile

This means each page is rendered and cached separately for mobile and desktop, consuming approximately twice the cache memory.

X-Prism-Variant Header

When viewport-aware rendering is enabled, PRISM adds an X-Prism-Variant response header:

X-Prism-Variant: mobile

or

X-Prism-Variant: desktop

This header serves two purposes:

  1. Debugging -- quickly identify which variant was served.
  2. CDN cache keying -- use this header as a Vary key or CDN cache key component so upstream CDNs maintain separate caches per device class. See CDN Integration for setup details.

Viewport Dimensions

The default viewport dimensions match common device profiles:

ClassWidthHeightMobile Flag
Mobile412px915pxtrue
Desktop1920px1080pxfalse

The mobile flag tells Chrome to emulate a mobile device, which affects CSS media queries (@media (max-width: ...)) and the navigator.userAgent viewport meta behavior.

Viewport dimensions are set on every render to ensure clean state on reused Chrome tabs.