<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gavin Clive</title>
    <description>The latest articles on DEV Community by Gavin Clive (@gavin_clive).</description>
    <link>https://dev.to/gavin_clive</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3906582%2Fd8b4753a-0394-4caf-ac5a-bdc4545db758.jpg</url>
      <title>DEV Community: Gavin Clive</title>
      <link>https://dev.to/gavin_clive</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gavin_clive"/>
    <language>en</language>
    <item>
      <title>Frontend Engineers Should Care More About Infrastructure</title>
      <dc:creator>Gavin Clive</dc:creator>
      <pubDate>Thu, 30 Apr 2026 18:47:23 +0000</pubDate>
      <link>https://dev.to/gavin_clive/frontend-engineers-should-care-more-about-infrastructure-id7</link>
      <guid>https://dev.to/gavin_clive/frontend-engineers-should-care-more-about-infrastructure-id7</guid>
      <description>&lt;p&gt;One &lt;code&gt;304 Not Modified&lt;/code&gt; is easy to ignore. A page full of them is latency.&lt;/p&gt;

&lt;p&gt;We migrated CDN providers that quarter.&lt;/p&gt;

&lt;p&gt;The new provider was meaningfully cheaper, and its edge coverage in Southeast Asia looked comparable. The migration itself went smoothly. Traffic moved over, error rates stayed normal, and the infra team signed it off.&lt;/p&gt;

&lt;p&gt;One thing had changed underneath us: the &lt;code&gt;Cache-Control&lt;/code&gt; headers our old provider had been injecting at the edge did not carry over.&lt;/p&gt;

&lt;p&gt;Before that migration, I did not think about those headers much. Not because they were unimportant, but because they had already been decided below the application layer. The asset pipeline emitted files, the CDN served them, the browser cached them, and the page worked.&lt;/p&gt;

&lt;p&gt;The new provider was still serving our static images correctly. &lt;code&gt;ETag&lt;/code&gt; was present. Repeat loads returned &lt;code&gt;304 Not Modified&lt;/code&gt;. Nothing obvious was being re-downloaded. At a glance, the network tab looked fine.&lt;/p&gt;

&lt;p&gt;Nothing was broken.&lt;/p&gt;

&lt;p&gt;That was what made it hard to spot.&lt;/p&gt;

&lt;p&gt;The browser was doing the responsible thing. The server was doing the responsible thing. DevTools showed small transfer sizes, and the status code looked like evidence that caching worked. If you were scanning for wasted bytes, you would move on.&lt;/p&gt;

&lt;p&gt;The LCP regression showed up two weeks later in RUM data.&lt;/p&gt;

&lt;p&gt;The moment it clicked was a Sentry trace from an icon-heavy page. It was not one suspicious request. It was a page full of tiny validations, all individually harmless-looking, sitting in the same trace. Together, they made the page feel like it was checking its pockets before every step.&lt;/p&gt;




&lt;p&gt;Without &lt;code&gt;Cache-Control&lt;/code&gt; or &lt;code&gt;Expires&lt;/code&gt;, the browser falls back to heuristic caching. Usually that means a short, unpredictable freshness window based on the gap between &lt;code&gt;Last-Modified&lt;/code&gt; and the current date.&lt;/p&gt;

&lt;p&gt;So repeat visits kept sending conditional &lt;code&gt;GET&lt;/code&gt; requests with &lt;code&gt;If-None-Match&lt;/code&gt; to ask whether the image had changed. The server replied &lt;code&gt;304&lt;/code&gt;. The image body was not downloaded again, but the browser still paid for a round trip before rendering the largest contentful element.&lt;/p&gt;

&lt;p&gt;In a Jakarta office on a fast connection, this was invisible.&lt;/p&gt;

&lt;p&gt;On a mid-range Android device on 4G, it compounded.&lt;/p&gt;

&lt;p&gt;LCP does not care that the requests ended in &lt;code&gt;304&lt;/code&gt;. It cares that rendering waited.&lt;/p&gt;

&lt;p&gt;I already knew a &lt;code&gt;304&lt;/code&gt; was not free. What I had not internalized was how invisible the aggregate could be. A validated cache hit saves bandwidth, but if a page is full of them, the latency still shows up in the trace.&lt;/p&gt;




&lt;p&gt;The distinction worth remembering is simple: &lt;code&gt;ETag&lt;/code&gt; asks, has this changed? &lt;code&gt;Cache-Control&lt;/code&gt; asks, do I need to ask right now?&lt;/p&gt;

&lt;p&gt;Without an explicit freshness policy, the browser can keep asking that question much sooner than you expect.&lt;/p&gt;

&lt;p&gt;For static product and UI images served at stable URLs, we should have been sending something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;Cache-Control: max-age=604800, stale-while-revalidate=86400
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seven days of freshness, with background revalidation after that. Repeat visits skip the validation request entirely, so the browser does not need to ask the edge before it can render.&lt;/p&gt;

&lt;p&gt;The important constraint is stable URLs. If the same URL can point to a different image tomorrow, a long &lt;code&gt;max-age&lt;/code&gt; is a footgun. But for versioned assets, product images with controlled invalidation, and UI images that do not change under the same path, freshness is the point.&lt;/p&gt;

&lt;p&gt;This is now one of the checks I wish I had treated as frontend work. Not just whether the image loads. Not just whether the status is &lt;code&gt;200&lt;/code&gt; or &lt;code&gt;304&lt;/code&gt;. Check the trace for repeated validation spans. Check the response headers on the actual LCP resource. Check whether those spans sit before the LCP mark.&lt;/p&gt;




&lt;p&gt;The infra team did nothing wrong. The migration was correct.&lt;/p&gt;

&lt;p&gt;The old provider had simply been doing us a quiet favor, and we did not know enough to notice when it stopped.&lt;/p&gt;

&lt;p&gt;That was the real bug.&lt;/p&gt;

&lt;p&gt;If I had paired that icon-heavy Sentry trace with the missing &lt;code&gt;Cache-Control&lt;/code&gt; header sooner, I would have found this in an afternoon instead of two weeks into a KPI cycle.&lt;/p&gt;

&lt;p&gt;After restoring explicit freshness on those media responses, repeat visits no longer had to validate the same image URLs before rendering.&lt;/p&gt;

&lt;p&gt;Sentry will tell you LCP is &lt;code&gt;4.2s&lt;/code&gt;. Chrome DevTools will show you the waterfall. But if the response headers read like a foreign language, you can spend weeks looking for a frontend bug that is not in the codebase.&lt;/p&gt;

&lt;p&gt;The browser is the last mile.&lt;/p&gt;

&lt;p&gt;Infrastructure is the road under it.&lt;/p&gt;

&lt;p&gt;Frontend engineers should know what it is made of.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>frontend</category>
      <category>performance</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
