Backend levers for frontend performance: response size and shape, Brotli/gzip compression, Cache-Control, ETag and immutable hashed assets, output caching, CDNs such as Azure Front Door, HTTP/2 and HTTP/3, early hints and preload, and measuring with Core Web Vitals (LCP, INP, CLS) and real-user monitoring.
The API's 80 ms is usually a small part of what users feel: round trips, bytes and browser work dominate. A backend engineer controls a lot of that. Shrink payloads with projection and pagination, and turn on Brotli/gzip (JSON shrinks 70–90%). Use HTTP caching properly: content-hashed JS/CSS get Cache-Control: public, max-age=31536000, immutable, HTML gets no-cache so deploys show up, and API GETs get ETags for cheap 304s. Put static and public content on a CDN like Azure Front Door with Australian points of presence. Enable HTTP/2 and HTTP/3, reduce chatty call sequences, and send preload or 103 Early Hints for critical assets. Then measure with Core Web Vitals at the 75th percentile from real users: LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1. Trade-off: aggressive caching is fast but needs versioned URLs or you'll serve stale code.
"The first thing I'd say is that 80 ms of server time doesn't mean an 80 ms experience. A page load is DNS, TLS, the HTML, CSS and JavaScript downloads, maybe a waterfall of API calls the SPA makes only after its bundle runs, then parsing and rendering on a phone that's much slower than my laptop. On a 4G connection in regional Queensland, every round trip might be 60–100 ms, so three sequential API calls after a 600 KB bundle easily become three seconds. I'd start by opening the Network panel's waterfall and a Lighthouse report, and checking field data, before changing anything.
Then the levers I own. Bytes: return what the screen needs, not entire entity graphs; paginate; enable response compression or let the CDN do Brotli. Caching: build tools like Vite emit content-hashed file names, so I serve those with a one-year
immutablecache and give the HTMLno-cache, which means 'revalidate every time', so a deploy is picked up immediately but nothing is downloaded twice. API GETs that rarely change get anETag; the browser sendsIf-None-Matchand I answer 304 with no body. Shared, non-personal responses can use ASP.NET Core output caching or the CDN. Distance: Azure Front Door terminates TLS close to the user and serves cached assets from Sydney or Melbourne edge locations. Protocol: HTTP/2 multiplexes requests on one connection, HTTP/3 over QUIC avoids TCP head-of-line blocking on lossy mobile links. Round trips: one aggregate endpoint for a screen instead of five sequential calls.The mistake I see is optimising server microseconds while shipping uncompressed 2 MB JSON with
no-storeon everything. And I'd prove the gain with Core Web Vitals from real users: LCP for loading, INP for responsiveness, CLS for layout stability, all at the 75th percentile."
| Lever | Mostly improves | ASP.NET Core / Azure feature |
|---|---|---|
| Smaller JSON (projection, paging) | LCP, INP (less parsing) | Select to DTOs, Take |
| Brotli/gzip | LCP, TTFB to last byte | AddResponseCompression, Front Door compression |
| Immutable hashed assets | Repeat-visit LCP | UseStaticFiles with OnPrepareResponse, MapStaticAssets |
| ETag + 304 | Bandwidth, LCP on revisits | EntityTagHeaderValue, output caching |
| CDN | TTFB, LCP | Azure Front Door, Azure CDN |
| HTTP/2, HTTP/3 | Connection overhead | Kestrel Protocols, Front Door |
| Fewer sequential calls | LCP | Aggregate/BFF endpoint |
| Server-rendered first view | LCP | Razor, Blazor static SSR, streaming |
| Reserve space for late content | CLS | Width/height on images, skeletons |
| Metric | Measures | Good |
|---|---|---|
| LCP (Largest Contentful Paint) | Loading of main content | ≤ 2.5 s |
| INP (Interaction to Next Paint) | Responsiveness to input (replaced FID in March 2024) | ≤ 200 ms |
| CLS (Cumulative Layout Shift) | Visual stability | ≤ 0.1 |
| TTFB (supporting) | Server + network to first byte | ≤ 0.8 s |
| Resource | Header |
|---|---|
app.3f9a1c.js, site.88b2.css |
public, max-age=31536000, immutable |
index.html |
no-cache |
| Public reference data API | public, max-age=300 + ETag |
| User-specific API | private, no-cache or no-store |
A product catalogue SPA served a 1.8 MB uncompressed JSON list and its bundle with no-store. Enabling Brotli at Front Door, paging to 50 items, and giving hashed assets a one-year immutable cache cut transferred bytes on repeat visits by 92% and moved p75 LCP from 4.3 s to 2.1 s for mobile users, measured with the Application Insights browser SDK over two weeks.
Checks that a backend engineer understands their influence on user-perceived performance and can measure it with the right metrics.
Green flags
Red flags
[DNS][TCP][TLS][ HTML ] <- TTFB + download
[ CSS ][ JS bundle ] <- render-blocking / parse
[API 1][API 2][API 3] <- waterfall after JS runs
[render] <- LCP
Each bracket is at least one round trip. Server processing is inside HTML and each API bar. The cheapest wins remove whole bars (caching, fewer sequential calls) or shrink them (compression, CDN proximity).
max-age lets the browser reuse without asking. immutable tells it not to revalidate even on reload.If-None-Match: "etag" (or If-Modified-Since). A 304 has no body.no-cache means "store but revalidate before use"; no-store means "don't store at all". They're often confused.private forbids shared caches (CDN, proxies) from storing it; essential for user data.Vary tells caches which request headers change the response (Accept-Encoding, Origin).Brotli at quality 4–5 for dynamic responses gives better ratios than gzip at similar CPU; static assets can be pre-compressed at maximum quality at build time (MapStaticAssets in .NET 9+ serves pre-compressed, fingerprinted files with correct ETags). Don't compress already-compressed formats (JPEG, PNG, WOFF2). Response compression over HTTPS is off by default in ASP.NET Core because of BREACH-style attacks when secrets and attacker-controlled input appear in the same compressed body; enable it deliberately, and avoid reflecting user input next to secrets.
A CDN shortens the TLS handshake (terminated at the edge) and serves cached content locally. Azure Front Door has edge sites in Sydney, Melbourne, Brisbane and Perth. HTTP/2 multiplexes many requests on one TCP connection; HTTP/3 runs over QUIC on UDP, so one lost packet doesn't stall every stream, which helps on mobile. Kestrel supports HTTP/3 on .NET 10 where the OS has QUIC support.
web-vitals JS library sending to Application Insights: what real users experience. Decide with field p75.AddResponseCompression with Brotli and compare transferred vs resource size in the Network panel.immutable and verify reloads show (memory cache).web-vitals library and log LCP, INP and CLS to the console for your own pages.Compression, immutable static assets, ETags and HTTP/3 in one ASP.NET Core app, plus field measurement.
// Program.cs (.NET 10)
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text.Json;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.AspNetCore.Server.Kestrel.Core;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(k => k.ConfigureEndpointDefaults(
l => l.Protocols = HttpProtocols.Http1AndHttp2AndHttp3)); // HTTP/3 where QUIC is available
builder.Services.AddResponseCompression(o =>
{
o.EnableForHttps = true; // deliberate: don't mix secrets with reflected input in one body
o.Providers.Add<BrotliCompressionProvider>();
o.Providers.Add<GzipCompressionProvider>();
});
builder.Services.Configure<BrotliCompressionProviderOptions>(o => o.Level = CompressionLevel.Fastest);
builder.Services.AddOutputCache();
var app = builder.Build();
app.UseResponseCompression();
// Fingerprinted Vite output (app.3f9a1c.js): cache for a year
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
var isHtml = ctx.File.Name.EndsWith(".html", StringComparison.OrdinalIgnoreCase);
ctx.Context.Response.Headers.CacheControl = isHtml ? "no-cache" : "public, max-age=31536000, immutable";
}
});
app.UseOutputCache();
// Public reference data: small, shared, ETag for cheap revalidation
app.MapGet("/api/categories", (HttpContext http) =>
{
Category[] data = [new(1, "Cables"), new(2, "Chargers")];
var bytes = JsonSerializer.SerializeToUtf8Bytes(data, JsonSerializerOptions.Web);
var etag = $"\"{Convert.ToHexString(SHA256.HashData(bytes))[..16]}\"";
http.Response.Headers.ETag = etag;
http.Response.Headers.CacheControl = "public, max-age=300";
if (http.Request.Headers.IfNoneMatch == etag) return Results.StatusCode(StatusCodes.Status304NotModified);
return Results.Bytes(bytes, "application/json");
}).CacheOutput(p => p.Expire(TimeSpan.FromMinutes(5)));
app.MapFallbackToFile("index.html"); // SPA entry point, served with no-cache
app.Run();
public sealed record Category(int Id, string Name);
// main.ts: send real-user Core Web Vitals to Application Insights
import { onLCP, onINP, onCLS } from 'web-vitals';
import { appInsights } from './telemetry';
for (const report of [onLCP, onINP, onCLS]) {
report((m) => appInsights.trackMetric({ name: m.name, average: m.value }, { rating: m.rating, page: location.pathname }));
}
no-store on every response. Why it is wrong: Hashed assets are downloaded on every visit. Instead: immutable for fingerprinted files, no-cache for HTML.max-age on index.html. Why it is wrong: Users keep old HTML pointing at deleted bundles after a deploy. Instead: no-cache on HTML; version assets by hash.public. Why it is wrong: A CDN can serve one user's data to another: a notifiable data breach. Instead: private or no-store for personalised data.The backend's biggest frontend lever is usually removing round trips and bytes rather than shaving server milliseconds: an aggregate endpoint per screen, sensible caching, compression and a CDN. Server-rendering the first view (Razor, Blazor static SSR or framework SSR) is the next step when LCP is dominated by a JS bundle that has to run before data is fetched.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Compression + caching headers | Always | Config only | Never skip |
| CDN (Front Door) | Public or static content, spread-out users | Monthly cost, cache invalidation | Purely internal apps on a LAN |
| Aggregate / BFF endpoint | Screens making 4+ calls | Endpoint per screen to maintain | Generic public APIs |
| Server-side rendering of first view | Poor LCP due to JS-then-fetch | Server CPU, hydration complexity | Highly interactive tools behind login where LCP matters less |
Measure before and after with field data: Application Insights browser telemetry or CrUX at p75, segmented by mobile vs desktop and by region, plus bytes transferred per page view.
Every response pays twice: serialisation time on the server and transfer time on the wire. On a phone over 4G with 60–100 ms RTT, a 2 MB JSON payload needs many TCP slow-start round trips, so it can take seconds even when the server answered in 40 ms. I shrink responses three ways:
Select in EF Core), so only the fields the screen uses are read and sent.I prove it with response bytes and client-side p95, not server time. The trade-off: compression costs CPU and needs care over HTTPS, and smaller pages mean more requests if the client really needs all the data.
A handful of headers carry most of an API's contract:
Bearer tokens; never in the URL.The trade-off: headers are invisible in most client code, so anything important must be documented in OpenAPI and handled by the framework, not by hand.
HTTP/2 sends many requests as multiplexed streams over one TCP connection, with binary framing and HPACK header compression, so you stop paying for extra connections and HTTP/1.1's one-request-at-a-time queue. But it still runs on TCP, so one lost packet stalls every stream: TCP head-of-line blocking.
HTTP/3 moves to QUIC over UDP with TLS 1.3 built in: each stream recovers from loss on its own, the handshake is faster (1-RTT, 0-RTT on resume), and connections survive a network change.
In .NET 10, Kestrel serves HTTP/1.1 and HTTP/2 by default. HTTP/3 is a one-line opt-in: MsQuic ships with .NET on Windows, and on Linux you install the libmsquic package. The gain is real on high-latency, lossy mobile networks with many parallel requests and for gRPC; for a single big response inside one Azure region it is usually noise. Measure per protocol before you claim it.
How to tell it (STAR)
**S:** Our [catalogue] API answered in under 100 ms, but mobile users found the page slow and [marketing] saw high bounce rates. **T:** I was asked to find out why from the backend side. **A:** I looked at field data and a throttled waterfall instead of server metrics, and found uncompressed megabyte-sized JSON, no caching on hashed bundles and three sequential API calls. I enabled Brotli at Front Door, set immutable caching on fingerprinted assets, paged and projected the catalogue response and merged the calls into one endpoint, then added Lighthouse CI budgets. **R:** Repeat-visit bytes fell by [about 90%] and p75 mobile LCP went from [4.3 s] to [2.1 s] over [two weeks], and [bounce rate improved by X].
Last updated 23 Nov 2026.