Serving images to mobile apps

Backends for mobile apps Junior Python 3.13+ PostgreSQL 17+ Reviewed By Best Latest Apps

Pick the fix

Feed thumbnails are 360 px wide but the API returns 4,000 px originals. Best fix?

Options
Hint 1 of 1

How many bytes does the phone actually need?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Serve allow-listed resized variants through a CDN and return the right size URL

Correct. Smaller bytes, cached at the edge.

Most of the cost is bytes over the phone's network. A fixed set of resized variants caches well at the CDN, and the allow-list stops clients asking for endless sizes.

Why not the others?
  • B Let the phone resize after download. Still downloads the full original.
  • C Compress the originals heavily. Hurts quality where full size is needed.
  • D Serve from the API server. No edge caching, more load.

30-second answer

Store originals in object storage and serve resized variants from a CDN. Either pre-generate a few sizes on upload, or use an on-the-fly resizing service behind the CDN with an allow-list of sizes so attackers can't request endless variants. Serve modern formats (WebP, AVIF) where supported, set long cache lifetimes with content-hashed URLs, and have the API return the URL for the size the client asks for.

Practise saying it · 25 s. No recording, just a timer

Image delivery.

Say your answer out loud, then check which of these points you covered:

  • Originals in object storage
  • Sized variants via CDN
  • WebP/AVIF
  • Hashed immutable URLs
  • Strip EXIF

Deep dive

Strip EXIF metadata, which can include location.

Blur-hash or dominant-colour placeholders improve perceived speed.

Content-hashed URLs mean you never need to purge caches.

Limit upload dimensions and pixels to avoid decompression bombs.

Common mistakes

  • Sending the 4,000-pixel original to a 360-pixel thumbnail.
  • Unbounded on-the-fly sizes.
  • Keeping GPS EXIF data on public images.

Senior take & follow-ups

Originals in storage, sized variants via CDN, formats, immutable URLs, safety.

Follow-up questions

Think of your answer first, then open the hint.

  1. Why an allow-list of sizes?

    Show hint

    Every new size is a cache miss and CPU work.

  2. Why strip EXIF?

    Show hint

    Privacy: it can contain the photo's location.

Suggest a fix if something here is wrong or out of date.