4.2 Optimize Browser Caching
Browser caching reduces the requirement for files to need to be constantly reloaded from the server, and in certain situations, it can even allow for files to be viewed offline (or in the case of a reverse proxy, send immediate recurring requests without additional calculation or computation from the server). As such, this will have sustainability and performance benefits (for instance by greatly reducing Time-To-First-Byte).
Criteria
- Server-side Caching: If using a CMS, install an applicable plugin to enable on-the-fly server-side caching. Otherwise, use the provided server configuration files to include and tweak the file-type cache expiration using expires, bfcache, or cache-control HTTP header. If using a language or framework that generates pages on request, cache responses for static pages so that they can be reused for future visitors.
- Offline Access: Client-side JavaScript uses a combination of ServiceWorkers, WebWorkers, storage Application Programming Interfaces (APIs), or cookies (if necessary) to streamline the user-journey. For example, through the use of a PWA (Progressive Web Application) to ensure that an offline version is available and accessible at all times to reduce inequality and improve accessibility.
Impact
High
Effort
High
Benefits
- Social Equity:
Allows websites to be functional in regions where no or intermittent Internet connectivity is available. - Performance:
Unmodified files don’t need to constantly be redownloaded (saving bandwidth, and server-side caching reduces the amount of computing resources required (as fewer HTTP requests will likely be submitted). Also, being selective over cached content balances faster reloads over the need to request new pages, which means that visitors may experience less latency due to data being held for repeat requests. - Economic:
Reduced data transfer allows for savings for individuals on a monitored data plan and infrastructure costs for the provider. - Conversion:
Caching increases repeat visitor page-load speeds (a customer benefit).
GRI
- materials: Medium
- energy: High
- water: Medium
- emissions: High
Example
- Code:
Expires: Wed, 01 Jun 2023 08:00:00 GMT
- HTTP expires headers can be used to control the response.
Resources
- A Web Caching Primer
- Apache Configuration: .htaccess
- Back/forward cache
- Client-side storage
- Digital Eco-Design: Go further in the approach
- Front-End Performance 2021: Build Optimizations
- Future trends of Green All Optical Networks and ICT Infrastructure in a large context
- [GPFEDS] 2.3 – Specifications (Connection Issues) (PDF)
- [GPFEDS] 6.2 – Front-End (Caching Mechanisms) (PDF)
- [GPFEDS] 7.1 – Back-End (Reusability Caching) (PDF)
- [GR491] 2-7032 – Browser Caches
- [GR491] 3-5015 – Cache Usage
- [GR491] 7-3051 – Search Utilization
- How to Build a Low-tech Website?
- Impact of New and Emerging Internet Technologies on Climate Change and Human Rights (PDF)
- Learn PWA
- Microsoft Azure WAF: Selecting Services
- Microsoft Azure WAF: Server VS Client Rendering
- Progressive web apps
- Progressive Web Apps: Going Offline
- Resilient web design
- Service workers
- Varnish Cache
- Web Caching 101
- What Does My Site Cost?