The WebEducation3 min read

Why your browser still shows the old website

Understand Cache-Control, ETag, 304 responses and safe updates to static CSS and JavaScript.

Caching is not a browser mistake

Browsers and intermediate caches can store responses so subsequent navigation is faster and consumes less bandwidth. If a resource is considered fresh, the browser may reuse its local copy without making another network request. Updating a file on a server therefore does not always mean that every visitor sees it immediately.

To understand the behavior, inspect the response headers in your browser’s network panel or with curl -I.

Freshness and validation are different

Cache-Control: max-age=3600 permits a cache to treat a response as fresh for up to one hour. no-cache does not forbid storage: it requires revalidation before reuse. no-store instructs caches not to store the response.

During revalidation, a browser can send If-None-Match using an earlier ETag. If the resource has not changed, the server can reply 304 Not Modified without transferring the complete body.

Version static assets

A reliable deployment pattern is to give changed CSS and JavaScript assets a new URL. Content-hashed filenames such as main.a43f2.css work particularly well: immutable assets may be cached for a long time, while HTML points to new filenames after deployment.

For a small manually maintained site, a query-string version such as /assets/styles.css?v=3 can also encourage clients to request a different URL, provided intermediate caches honor it.

If HTML is updated but the stylesheet URL stays unchanged with a long freshness lifetime, users may see an inconsistent mix of new markup and old styling.

Deploy without half-written pages

When replacing several files, upload them to a separate release directory and switch a symlink or directory reference when the set is complete. This avoids visitors requesting an updated HTML page while some referenced assets are still missing.

Caddy’s file_server reads files from disk for incoming requests; changing a static HTML file does not require restarting Caddy. Whether a visitor sees the latest bytes still depends on browser and intermediary caching.

← All articles
SELECTED READING

Keep exploring

View all articles