What Are Signed Exchanges (SXG)? #
- SXG lets Google prefetch your site’s key resources (HTML, JS, CSS, images, fonts) while preserving user privacy.
- Prefetching means faster page rendering when users click your result, improving Largest Contentful Paint (LCP) and overall page experience.
Benefits for Your Site #
- Faster loading times for users from Google Search results.
- Potentially better Core Web Vitals, especially LCP.
- Works with both AMP and non-AMP pages.
How to Implement SXG #
- Follow web.dev’s detailed SXG guide for the implementation process.
- For AMP pages, follow the amp.dev SXG guide specifically tailored for AMP.
- After implementation, use Chrome’s guide to optimizing LCP with SXG to tune performance.
Important Google Search Requirements #
- Cache Expiration:
- Set SXG expiration dates carefully to ensure fresh content:
- Less than your HTTP cache expiration date.
- Less than 1 day in the future if the content has JavaScript or inline JS.
- Otherwise, less than 7 days in the future.
- Less than your HTTP cache expiration date.
- Set SXG expiration dates carefully to ensure fresh content:
- Handling Personalized Content:
- Move personalized or dynamic parts (like shopping carts) out of the SXG or lazy-load them.
- Alternatively, use Vary: Cookie signed header so SXGs are served only to users without cookies.
- Move personalized or dynamic parts (like shopping carts) out of the SXG or lazy-load them.
- Responsive Design:
- Prefer building pages with responsive design.
- Prefer building pages with responsive design.
Or serve separate desktop/mobile URLs, or specify non-responsive pages using:
<meta name=”supported-media” content=”only screen and (max-width: 640px)”>
Monitoring and Debugging SXG #
- Use web.dev’s SXG debugging tools for validation and troubleshooting.
- Use the SXG Validator Chrome extension to check if your SXG meets Google cache requirements.
To test Google’s SXG cache for a URL, convert the URL to a special cache URL format:
https://signed–exchange–testing-dev.webpkgcache.com/doc/-/s/yourdomain.com/path
- Check headers:
- Warning: indicates cache compliance errors.
- Location: means cache hasn’t fetched the SXG yet (not an error).
- Warning: indicates cache compliance errors.
- Google will recrawl your site periodically based on crawl speed and cache expiration.
- For AMP pages, use the AMP status report and URL Inspection tool in Search Console for SXG errors.
Stay Updated #
- Subscribe to the webpackaging-announce mailing list to get updates on SXG tooling, cache changes, and best practices.
TL;DR: #
Implement SXG to speed up page load from Google Search results by allowing privacy-preserving prefetching. Follow official guides for implementation, ensure cache expiration is set correctly, handle personalized content carefully, and monitor with Google and Chrome tools.