Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

Tech

HTTP Caching Explained: max-age, ETag and Why Your Users Still See Last Week's CSS

📺 Prefer to watch? 90-second YouTube Short · 💬 Telegram Originally published on software-engineer-blog.com . You fixed the CSS. You deployed. You opened the site and checked it yourself — perfect. Then a customer sends a screenshot of last week's layout. Nothing is broken. No deploy failed, no CDN is lying to you, no file is corrupt. The browser is doing exactly what you told it to do, several…

When you fix a CSS issue and deploy it, opening the site yourself confirms everything is working. However, a customer sends a screenshot of an outdated layout. The browser is following the established caching contract, delivering last week's CSS despite the update. This demonstrates caching's role in web performance, often overlooked as merely a setting rather than a contract with consequences.

The example uses PlantPal, a small plant shop website featuring one stylesheet (app.css), one logo (logo.png), and one API endpoint (/api/products). A page load involves approximately 40 separate requests, transferring about 1.2 MB of data and taking roughly 2.1 seconds to provide a usable page. The key takeaway is that the fastest request is the one the browser never sends.

Cache-Control: max-age=31536000 instructs browsers to store and reuse a file for a year without further requests. This is the blunt instrument of caching, intending to minimize unnecessary trips to the server. When a user revisits the site, the browser reads the cached app.css file from their disk, resulting in a 0 ms response time. However, this is not a fast request; it's a no request situation, with no server interaction, bandwidth usage, or potential network issues.

Cache-Control is a directive to all caches along the path from the server to the user, including CDNs, proxies, ISPs, and the browser. This powerful control can lead to unintended consequences, such as serving outdated content to multiple users simultaneously. The private directive can mitigate this risk by preventing shared caches from storing user-specific content.

Once you've implemented the fix, you must realize that the fixed version will be served to any subsequent requests for one year. This creates an asymmetry, as the cached version remains in users' browsers for an extended period, regardless of their location or subsequent visits. The cache's promise cannot be revoked once set, leading to potential performance issues if not managed carefully.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Now, where does it hurt?

While telemedicine isn't explicitly part of the NHI, it could become one of the key delivery mechanisms for the universal healthcare plan.

1a vez trabalhando com git com time: tudo que você precisa saber

Faz mais de 5 anos que eu não abria um PR ou issue técnica no Github, mas essa semana tenho aprendido algumas boas práticas e termos que reuni neste artigo.

  • Git branches allow parallel work on projects without affecting the official version
  • Create a branch per contribution to isolate errors if something goes wrong
  • PR descriptions should be concise summaries, not line-by-line lists

More from Thursday 20 August →