Frontend Development 11 min read

Understanding Browser HTTP Caching: Mechanisms, Forced and Negotiated Cache

This article explains the fundamentals of browser HTTP caching, detailing request and response structures, the processes of forced and negotiated caching, cache-control directives like Expires and Cache-Control, and how browsers store and retrieve resources from memory and disk caches.

Architecture Digest
Architecture Digest
Architecture Digest
Understanding Browser HTTP Caching: Mechanisms, Forced and Negotiated Cache

Overview

Browser caching, also known as HTTP caching, relies on cache directives in HTTP messages. HTTP messages consist of request and response formats, each containing a start line, headers (general, request/response, entity), and an optional body.

Cache Process Analysis

When a browser makes a request, the server returns a response with cache directives. The browser decides whether to store the result and its cache identifier based on these directives, and subsequently checks the cache before each request.

Forced Cache

Forced cache checks the browser’s cache and applies rules to decide if the cached result can be used. It has three cases: no cached entry (fetch from server), cached entry expired (fallback to negotiated cache), and cached entry valid (use cached result).

The server controls forced caching via Expires and Cache-Control headers, with Cache-Control taking precedence.

Expires

Expires (HTTP/1.0) provides an absolute expiration time; if the client’s clock is earlier than this time, the cached response is used.

Cache-Control

Cache-Control (HTTP/1.1) is the primary directive, supporting values such as public , private , no-cache , no-store , and max-age=seconds . When both Expires and Cache-Control are present, Cache-Control wins.

Browsers store cached resources in memory (fast, temporary) or on disk (slower, persistent). Memory cache is used for JavaScript and images, while CSS often resides in disk cache.

Negotiated Cache

If forced cache is invalid, the browser sends a conditional request with cache validators. The server decides whether to return a 304 Not Modified (use cache) or a fresh 200 response.

Validators include:

Last-Modified / If-Modified-Since

Etag / If-None-Match (higher priority than Last-Modified)

Etag/If-None-Match takes precedence; if they match, the server returns 304.

Summary

Forced caching (Expires, Cache-Control) is checked first; if it succeeds, the cached response is used. Otherwise, negotiated caching (Last-Modified/If-Modified-Since, Etag/If-None-Match) determines whether the resource can be reused (304) or must be fetched anew (200).

frontendCachingweb performanceHTTPbrowsercache controlExpires
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.