Leverage Browser Caching
What is Browser Caching?
Benefits of Browser Caching
Browser caching also helps reduce workload on the web server, as the browser is now responsible for taking care of some of the heavy lifting and saving these assets locally for future use. PageSpeed recommends reviewing all static assets and setting cache expires dates at a minimum of one month, but no more than a year out. For dynamic assets, it is recommended to cache those resources until they are updated and set a browser fingerprint, which tracks your browsing history and gives other sites information about your browser. This might seem like an invasion of your privacy, but it is really concerned more about your browser settings, rather than specific user information, although serving advertisements is a big part of it.
Recommendations for Browser Caching
Not implementing bowser caching has its disadvantages. Your users and visitors will have to pull all the resources and elements from your pages each time, which is not efficient. Continually having the server and browser serving, fetching, and rendering resources each time the page is visited is not ideal from a business or user perspective. It is expensive and ruins the user experience. Each page resource should be evaluated as to whether caching should be carried out, for how long, and by whom. The important thing about modern server frameworks and CDNS, for example, is that a lot of the caching policies are set automatically.
Browser Caching: Additional Considerations
However, not everything is set automatically, so make sure you set your HTTP cache behavior, request, and response headers, as necessary. Depending on the resource being requested, you may set your cache expiry out as far as a year. For content that changes regularly, you may want to set those to expire in less than an hour, or even earlier. Appropriately setting your cache headers (cache-control, expires, etc.) giving you better control over how resources are delivered. Caching provides a better experience for users and removes the burden of having to rely on your web server, and its resources (CPU, memory, network bandwidth, etc.) every time a page is requested. In the next section, we talk about the performance benefits of leveraging proxy caching.
Lighthouse is an open-source tool that is used to run an audit against your web pages and provides scores and suggestions for improving page performance, accessibility, SEO, and more.
PageSpeed Insights is a tool created by Google that reports on the performance of a page on both mobile and desktop devices, and provides suggestions on how that page may be improved.