In the Chrome browser, you can use the Network panel within Developer Tools to view the specific durations of various stages during webpage loading. These stages include Redirects, AppCache checks, DNS Lookup, TCP Handshake, Request sent, Waiting (TTFB), and Content Download. By analyzing these durations, you can target the optimization of webpage loading performance.
Here are several steps and recommendations for optimizing performance based on Chrome Timing information:
-
Reduce Redirects
- Optimization Point: Each redirect adds extra network latency. To minimize this, reduce or eliminate unnecessary redirects.
- Example: If your website automatically redirects from
http://example.comtohttps://example.com, this is necessary. However, if a user inputshttp://example.com/pageand is redirected tohttps://example.com/page, then further redirected due to a missing trailing slash tohttps://example.com/page/, these additional redirects can be optimized.
-
Optimize DNS Lookup
- Optimization Point: DNS lookup time can be reduced using DNS pre-fetching techniques.
- Example: Adding
<link rel="dns-prefetch" href="//example.com">to HTML pre-fetches the domain, reducing DNS resolution time for users accessing it.
-
Optimize TCP Handshake
- Optimization Point: Reducing TCP handshake occurrences typically decreases server connections. This can be achieved by using HTTP/2 for concurrent request transmission or maintaining persistent connections.
- Example: Enabling HTTP/2 allows multiple requests to be sent concurrently over the same TCP connection, reducing handshake needs.
-
Reduce Request Sent Time
- Optimization Point: Request sent time can be optimized by minimizing request size, such as reducing cookie size.
- Example: If cookies between server and client are excessively large, reduce cookie usage or store non-essential data in the client's localStorage.
-
Reduce Time to First Byte (TTFB)
- Optimization Point: Server response speed can be improved by optimizing server performance or enhancing backend response speed.
- Example: Optimize slow queries, implement caching for frequently requested data, or upgrade server hardware.
-
Optimize Content Download Time
- Optimization Point: Content download time can be shortened by reducing resource size or optimizing server bandwidth utilization.
- Example: Compress images and text files using Gzip or Brotli, and ensure sufficient server bandwidth for peak traffic.
-
Use Browser Cache Strategies
- Optimization Point: Properly configuring cache strategies reduces redundant resource downloads.
- Example: Set appropriate cache times for static resources (e.g., CSS, JS, image files) and use ETag or Last-Modified headers to verify resource updates.