A "good" response time is highly context-dependent. For interactive web applications, users typically expect response times under 2-3 seconds. For API calls or background processes, acceptable times can be much longer. Key metrics include Time to First Byte (TTFB), First Contentful Paint (FCP), and Largest Contentful Paint (LCP).
Performance can be measured using various tools and techniques:
Common bottlenecks include:
Optimizing images is crucial:
<picture>
element or srcset
attribute to serve appropriately sized images based on the user's device.loading="lazy"
attribute.Caching is the process of storing copies of files or data in a temporary storage location (cache) so that they can be accessed more quickly. This reduces the need to fetch data from the original, slower source.
Types of caching include:
By serving cached content, applications reduce server load and decrease response times, leading to a faster user experience.
HTTP/2 offers significant performance improvements over HTTP/1.1:
These features collectively reduce latency and improve the speed at which web pages load.