skip to content

As the lead for a fashion catalogue app's image delivery, how would you define the size, format and quality contract shared by every screen and every installed build?

level: principalimportance: should knowfreq 25%

answer

  1. one descriptor, every surface
  2. the server owns the ladder
  3. quality falls as density rises
  4. add freely, retire by snapping
  5. measure bytes, hits and failures

basics

~20 s

One server-owned image descriptor for every screen: a width ladder, formats with a JPEG fallback, quality by density, and placeholder data. Grow it without app releases, never break old builds, and steer it by bytes, hit rate and decode failures.

solid answer

~50 s

I would make images a single contract rather than a per-screen habit. Every API response carries the same image descriptor: aspect ratio, placeholder, a URL template, and the allowed widths. The app's only logic is shared: pixels from layout times density, round up, pick the best decodable format, send any low-data preference it already knows as a parameter. The server owns the ladder, the formats and a **quality table by density**, because a denser screen usually tolerates a lower quality setting, so bytes grow less than pixels. Changes follow expand and contract: add a width or format for clients that ask, and retire one by snapping old requests to a neighbour, never with errors, because builds two years old still call. Then I would run it on numbers: bytes per session on cellular, CDN hit rate per bucket, time to first image, and decode failures by OS release and app version.

go deeper

for a junior

Remember that images follow one shared rule across the app, so screens describe a view size and the server decides the rest.

for a middle

Explain the descriptor's fields and why the width list, formats and quality live on the server while only the pixel rule ships in the app.

for a senior

Show the safe-change discipline: add freely, retire by snapping, keep JPEG, and use telemetry by app version to decide when an old rule can go.

for a principal

Own the trade-offs: ladder steps against hit rate, quality against bytes by density, which levers each team may move, and the metrics that justify each change.

## Why a contract and not a habit In a fashion catalogue app, images appear on the home feed, category grids, search results, the product gallery, zoomable detail shots, the basket and order history. If each screen's team builds its own URLs, the estate drifts: one screen asks for originals, another invents a width, a third forgets the format list, and the CDN holds dozens of near-identical copies of every photo. The lead's job is to make the right request the **only easy request**. There is no single correct ladder or quality setting; the decision is which levers exist, who owns each one, and how they change safely. ## The descriptor every response carries Every API that returns a product returns its images in the same shape, defined once: - **identity**: a stable image id and a content version, so a re-shot photo gets a new URL rather than a purge; - **shape**: aspect ratio or original dimensions, for layout before pixels; - **placeholder**: a dominant colour and an optional short encoded blur, computed at ingest; - **request rule inputs**: a URL template with width and format slots, and the allowed widths for this image (capped at what the original can honestly produce). The app has one shared component that turns a view's layout size into a request: layout size times density, round up to the ladder, best format the device decodes, plus any parameter the app already knows it should send, such as a low-data preference detected elsewhere. Screens supply a view size and nothing else. ## The levers and their owners | Lever | Owned by | Changes without an app release? | Main trade-off | |---|---|---|---| | Width ladder | Media platform team, on the server | Yes, if the list comes from the server | Waste from rounding up against cache keys and origin cost | | Format list and order | Media team plus server encoders | Adding yes; decode support is the device's | Smaller files against encode time, storage and old devices | | Quality per density | Server encoding policy | Yes | Bytes against visible artefacts | | Placeholder kind | Ingest pipeline | Yes, as data | Response size against likeness | | Density cap per surface | Product and media, as a maximum width in the descriptor | Yes | Sharpness on dense screens against bytes on cellular | | Request rule (pixels, round up) | Shared client component | No, it ships in the app | Must be right from day one; old builds keep their version | ## Quality versus bytes The number of pixels grows with the square of density: a 3x screen needs 2.25 times the pixels of a 2x screen for the same layout size. Bytes need not grow that fast. On a denser screen each pixel is physically smaller, so compression artefacts are harder to see, and a lower encoder quality setting usually looks the same. That is common practice, not a constant: the server keeps a **quality table** keyed by the density bucket a request implies, and the media team tunes it by comparing samples on real devices. Some surfaces, such as a grid thumbnail, can also cap the density they request, since a small cell shows less detail than a zoomed product shot. ## Changing it safely when old builds are installed Builds up to two years old are still installed, and each one has the request rule it shipped with. 1. **Adding** a width, a format or a quality tier is safe: only clients that ask for it get it. 2. **Retiring** a width means the edge keeps **snapping** that width to its nearest neighbour; an old build's request is never answered with an error. 3. **Retiring** a format happens only when telemetry shows no installed build requests it, and JPEG is never retired. 4. The edge accepts only the published ladder, which keeps the cache warm and closes the door on cache-busting with arbitrary widths. ## How you know it works - **Bytes per session on cellular**, split by surface, to catch a screen that requests too large. - **CDN hit rate per bucket**, to see whether the ladder concentrates traffic or a rarely used step only adds keys. - **Time to first image** in the grid, with the placeholder paint as its own mark. - **Decode failures by OS release, app version and format**, to catch a negotiation mistake within hours. - **Requests for unlisted widths by app version**, to know when an old rule can finally be retired. ## The judgment in the answer The strong answer does not quote a magic ladder. It shows that the policy is centralised where it can change freely (the server), minimal where it cannot (the app's request rule), conservative about the installed base, and steered by the numbers above. How the CDN caches, how the device decodes, and how the app detects a low-data mode are owned elsewhere; this contract is what ties them to one request.

  • A product team asks for a 'crisp mode' that always requests 3x images in the grid. How do you respond?
    Ask what problem it solves, then make it a ladder or quality-table change on the server if it is justified, measured against bytes per session and hit rate. It should not be a per-screen exception in the client, because that bypasses the shared rule and ships to old builds never.
  • Telemetry shows a two-year-old build still requests a width you removed from the ladder. What now?
    Keep snapping that width to its neighbour at the edge, which costs almost nothing, and watch the share of requests by app version. Remove the snap only when that build's traffic is negligible; returning errors would blank its images.

  • Let each screen's team build its own image URLs and sizes.
  • Bytes must grow in step with pixels, so 3x costs 2.25 times 2x.
  • Removing a width from the ladder is safe once the current build stops using it.
  • The quality setting should be one global number for every density and surface.
  • Adding a new image format forces every installed build to update.