使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
开始在 Google 搜索中使用 Signed Exchange
Signed Exchange (SXG) 让 Google 搜索能够预提取您的内容,同时又不损及用户隐私。在实践中,这意味着如果相关网站支持 SXG,则 Google 搜索中显示的 AMP 和非 AMP 结果可能会以注重隐私保护的方式预提取一些关键资源(例如 HTML、JavaScript、CSS、图片或字体)。
当用户最终点击结果时,由于已有可用的关键资源,网页会更快地开始渲染,从而提供更出色的用户体验。因此,内容的 Largest Contentful Paint (LCP) 得分可能会降低,进而从整体上改善网页体验。
实现 SXG
如需实现 SXG,请遵循 web.dev 上的详细指南。实现此机制后,请按照 Chrome 指南:使用 Signed Exchange 优化 LCP 进行操作。
对于 AMP 网页,请遵循 amp.dev 上的详细指南。
Google 搜索的其他要求
Google 使用 SXG 缓存来预提取内容。Google 可能会多次提供这些缓存的 SXG。
为了确保在 Google 搜索中显示最新内容,请适当设置 SXG 的失效日期。一般来说,应确保失效日期早于以下两个日期:
- 由 HTTP 标头确定的缓存失效日期
- 如果内容是 JavaScript 或内联 JavaScript,则为 1 天后;否则为 7 天后
为了确保内容在多种设备上提供时能正确显示,请执行以下操作:
- 将个性化内容(如购物车)迁移到 SXG 外部的延迟加载元素中。或者,也可以添加带有
Vary: Cookie
签名的标头;带有此标头的 SXG 将只向您网站的没有 Cookie 的访问者显示。
- 采用自适应设计构建网页。或者,使用单独的网址提供桌面版和移动版网页,或使用
supported-media
meta
标记为网页添加注释,声明网页不是自适应网页。
例如,在网页的 <head>
元素中添加以下标记:
<meta name=supported-media content="only screen and (max-width: 640px)">
监控和调试 SXG
如需了解有哪些工具可用于调试 SXG,请参阅 web.dev 上的 SXG 工具指南。
如果 Googlebot 无法解析 SXG,则可能会重新抓取 Accept
标头中不带 application/signed-exchange;v=b3
的网址,以检索 text/html
变体。如果出现任何 SXG 索引编制错误,Google 搜索都会链接到未实施 SXG 的原始网址。
对于 AMP 网页,请使用 Search Console 中的“AMP 状态”报告监控 SXG 错误。
调试 Google SXG 缓存
如需确定 SXG 是否符合缓存要求,请使用 SXG Validator Chrome 扩展程序。
或者,请直接查询 Google SXG 缓存。
例如,如果 SXG 网址为 https://signed-exchange-testing.dev/sxgs/valid.html
,则相应的缓存网址格式如下:
https://signed--exchange--testing-dev.webpkgcache.com/doc/-/s/signed-exchange-testing.dev/sxgs/valid.html
用于计算子网域和网址路径后缀的算法与 AMP Cache 相同,但中缀字符串 /doc/-/
有所不同。
如果响应为 SXG,这意味着来自源服务器的响应符合 Google SXG 缓存要求。否则,响应中将包含指明原因的 HTTP 标头。
- 如果存在
Warning
标头,则表示出现了错误,导致 SXG 不符合缓存要求。
- 如果存在
Location
标头,则表示相应资源尚未被缓存系统提取。这不是 SXG 中存在的错误。
无论给出了怎样的响应,缓存系统都会在队列中加入一个对原始网址的请求,以获取一份最新副本。多种因素都会影响系统何时以及是否发出此请求,包括 Googlebot 抓取您网站的速度有多快。
Google 缓存 SXG 的时间不会超出 SXG 签名的 expires
值或 SXG 响应的未签名标头的新鲜度生命周期。
对于 AMP 网页,可以使用网址检查工具调试缓存错误。
订阅 webpackaging-announce 邮寄名单,随时掌握关于以下变更的最新消息:
- Google SXG 缓存系统的变更,包括增添新功能或弃用现有功能的变更。
- SXG 工具 Web Packager、NGINX SXG 模块和 libsxg 的重大变更。
如果您对在 Google 搜索中使用 SXG 有任何疑问,请访问搜索中心帮助社区。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-04。
[null,null,["最后更新时间 (UTC):2025-08-04。"],[[["\u003cp\u003eSigned Exchanges (SXGs) enable Google Search to prefetch website content, enhancing user experience by speeding up page load times while maintaining privacy.\u003c/p\u003e\n"],["\u003cp\u003eImplementing SXGs involves following specific guides for general websites and AMP pages, ensuring content is optimized for Google Search.\u003c/p\u003e\n"],["\u003cp\u003eGoogle caches SXGs and recommends setting appropriate expiration values to keep content up-to-date in search results.\u003c/p\u003e\n"],["\u003cp\u003eFor content to display correctly across devices, developers should consider lazy-loading personalized elements or implementing responsive design techniques.\u003c/p\u003e\n"],["\u003cp\u003eMonitoring and debugging SXGs involves utilizing various tools and resources, including Chrome extensions and Google Search Console, to identify and resolve potential issues.\u003c/p\u003e\n"]]],["Signed exchanges (SXG) enable Google Search to prefetch website content, improving user experience by reducing page load times. To implement SXG, use guides from web.dev or amp.dev (for AMP pages). Ensure up-to-date content by setting SXG expiration to less than one day (for JavaScript) or seven days, or less than the HTTP cache expiration. Optimize for multiple devices, and use debugging tools like the SXG Validator extension. Monitor SXG performance and errors via Google Search Console, and stay informed of updates via the webpackaging-announce mailing list.\n"],null,["# Signed Exchanges on Google Search | Google Search Central\n\nGet started with signed exchanges on Google Search\n==================================================\n\n\n[Signed exchanges](https://web.dev/articles/signed-exchanges) (SXG) allow\nGoogle Search to prefetch your content while preserving the user's privacy. In practice, this\nmeans that both AMP and non-AMP results shown on Google Search may prefetch a few key\nresources (such as HTML, JavaScript, CSS, images, or fonts) in a privacy-preserving manner,\nif the associated website supports SXG.\n\n\nWhen the user ultimately clicks the result, the web page starts rendering much sooner since\nkey resources are already available, leading to a better user experience. This could mean a\nlower [Largest Contentful Paint (LCP)](https://web.dev/articles/lcp) score\nfor your content, which can improve\n[page experience](/search/docs/appearance/page-experience) overall.\n\nImplement SXG\n-------------\n\n\nTo implement SXG, follow [web.dev's\nin-depth guide](https://web.dev/articles/signed-exchanges#tooling). After implementing, follow\n[Chrome's guide to optimizing LCP using Signed Exchanges](https://developer.chrome.com/blog/optimizing-lcp-using-signed-exchanges).\n\n\nFor AMP pages, follow [amp.dev's in-depth guide](https://amp.dev/documentation/guides-and-tutorials/optimize-and-measure/signed-exchange/).\n\n### Additional requirements for Google Search\n\n\nGoogle uses a cache of SXG to prefetch your content. Google may serve these cached SXG\nmultiple times.\n\n\nTo make sure that up-to-date content displays in Google Search, set the SXG expiration values\nappropriately. As a rule of thumb, make sure that the expiration date is less than both of these dates:\n\n- The cache expiration determined by your HTTP headers\n- 1 day in the future if the content is JavaScript or inlines JavaScript; otherwise 7 days in the future\n\n\nTo make sure that content displays properly when served on multiple devices, do the following:\n\n1. Move personalized content, such as shopping carts, into lazy-loaded elements that are outside of the SXG. Alternatively, add the `Vary: Cookie` signed header; SXGs with this header will be shown only to visitors without a cookie for your site.\n2. Build the pages with [responsive web design](https://web.dev/articles/responsive-web-design-basics). Alternatively, serve desktop and mobile pages on [separate URLs](/search/docs/crawling-indexing/mobile/mobile-sites-mobile-first-indexing#separate-urls), or annotate the pages to state that they aren't responsive, using the [`supported-media` `meta` tag](https://github.com/google/webpackager/blob/main/docs/supported_media.md). For example, in the page's `\u003chead\u003e` element, add the following tag: \n\n ```text\n \u003cmeta name=supported-media content=\"only screen and (max-width: 640px)\"\u003e\n ```\n\nMonitor and debug SXG\n---------------------\n\n\nFor a list of tools that you can use to debug SXG, check out [web.dev's guide to SXG tools](https://web.dev/articles/signed-exchanges#tooling).\n\n\nIn the event that Googlebot can't parse an SXG, it may recrawl the URL without `application/signed-exchange;v=b3`\nin the `Accept` header, in order to retrieve the `text/html` variant. In\nthe event of any SXG indexing error, Google Search will link to the original URL, without SXG.\n\n\nFor AMP pages, use the [AMP\nstatus report](https://support.google.com/webmasters/answer/7450883) in Search Console to monitor [SXG errors](https://support.google.com/webmasters/answer/7450883#sgx_warning_list).\n\nDebug the Google SXG cache\n--------------------------\n\n\nTo determine whether SXG meets the cache requirements, use the\n[SXG Validator Chrome extension](https://chrome.google.com/webstore/detail/sxg-validator/hiijcdgcphjeljafieaejfhodfbpmgoe).\n\n\nAlternatively, query the Google SXG cache directly.\nFor example, if the SXG URL is `https://signed-exchange-testing.dev/sxgs/valid.html`, formulate\nthe corresponding cache URL:\n\n\n`https://signed--exchange--testing-dev.webpkgcache.com/doc/-/s/signed-exchange-testing.dev/sxgs/valid.html`\n\n\nThe algorithm for computing the subdomain and the URL path suffix is the\n[same as for the AMP Cache](https://amp.dev/documentation/guides-and-tutorials/learn/amp-caches-and-cors/amp-cache-urls/),\nwhile the infix string `/doc/-/` is different.\n\n\nIf the response is a SXG, then this means the response from the origin server meets the\nGoogle SXG [cache requirements](https://github.com/google/webpackager/blob/main/docs/cache_requirements.md).\nOtherwise, it will include an HTTP header that indicates the reason.\n\n- If there is a `Warning` header, then it indicates an error that prevented the SXG from meeting the cache requirements.\n- If there is a `Location` header, then it has not yet been fetched by the cache. This is not an error in your SXG.\n\n\nRegardless of the response, the cache enqueues a request to the original URL for an updated\ncopy. There are several factors for when and if this request happens, including how fast\nGooglebot can crawl your site.\n\n\nGoogle doesn't cache SXGs for longer than the `expires` value of the SXG signature\nor the\n[freshness\nlifetime](https://datatracker.ietf.org/doc/html/rfc7234#section-4.2.1) of the unsigned headers of the SXG response.\n\n\nFor AMP pages, you can use the\n[URL Inspection Tool](https://support.google.com/webmasters/answer/9012289)\nto debug caching errors.\n\nStay informed\n-------------\n\n\nSubscribe to the [webpackaging-announce](https://groups.google.com/g/webpackaging-announce)\nmailing list to stay up-to-date with the following changes:\n\n- Changes to the Google SXG cache that enable new capabilities or deprecate other capabilities.\n- Major changes to the SXG tools Web Packager, NGINX SXG module, and libsxg.\n\n\nIf you have questions about SXG on Google Search, visit the\n[Search Central Help Community](https://support.google.com/webmasters/community)."]]