Skip to content
学习 衡量 博客 Case studies 关于
Join and donate to 🇺🇦 DevFest for Ukraine, a charitable tech conference happening June 14–15 supported by Google Developers and Google Cloud.
本页内容
  • Lighthouse 多个重定向审计如何失败
  • 程序栈特定的指南
    • React
  • 资源

避免多个页面重定向

May 4, 2019 — 更新日期 Sep 19, 2019
Available in: Español, 한국어, Português, Русский, English
Appears in: 性能审核
本页内容
  • Lighthouse 多个重定向审计如何失败
  • 程序栈特定的指南
    • React
  • 资源

重定向会减慢页面加载速度。当浏览器请求已重定向的资源时,服务器通常会返回如下 HTTP 响应:

HTTP/1.1 301 Moved Permanently
Location: /path/to/new/location

然后,浏览器必须向新位置发出另一个 HTTP 请求才能检索资源。这种额外的跨网络行程可能使资源的加载延迟数百毫秒。

Lighthouse 多个重定向审计如何失败 #

Lighthouse 会标记具有多个重定向的页面:

当页面有两个或更多重定向时,该页面无法通过此审计。

如何消除重定向 #

将指向标记的资源的链接指向资源的当前位置。在关键渲染路径所需的资源中避免重定向尤为重要。

如果您使用重定向将移动用户转移到页面的移动版本,请考虑重新设计网站以使用响应式设计。

程序栈特定的指南 #

React #

如果使用 React Router,请尽量减少使用 <Redirect> 组件进行路由导航。

资源 #

  • 避免多个页面重定向审计的源代码
  • HTTP 中的重定向
  • 避免登陆页面重定向
Last updated: Sep 19, 2019 — Improve article
Return to all articles
分享
订阅

Contribute

  • 提交错误
  • 查看源代码

相关内容

  • developer.chrome.com
  • Chrome 动态
  • 网站开发基础
  • 案例研究
  • 播客
  • 节目

连接

  • Twitter
  • YouTube
  • Google Developers
  • Chrome
  • Firebase
  • Google Cloud Platform
  • 所有产品
  • 条款和隐私权
  • 社区准则

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies.