Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Serve Tiles with CloudFront

TL;DR
Add CloudFront in front of your S3 bucket to cache tiles and reduce latency and cost at scale. Good for public tiles with moderate to high traffic.

Tiles with CloudFront architecture

Description

User requests a tile → CloudFront checks its edge cache → if not found, it fetches from S3 → response is cached at the edge for future use.

This pattern extends Public Tiles with S3 by placing a CloudFront distribution in front of the S3 bucket. CloudFront caches tile requests at edge locations, reducing latency and minimizing S3 request charges. This setup is especially useful for production deployments of public tile sets.

When to Use

  • Serving public tile sets at scale
  • Reducing S3 request and data transfer costs
  • Lowering latency for end users globally
  • Light or moderate access control needs (e.g. cookie-based auth)

Trade-offs

  • Signed requests are secure but too slow for tile serving
  • Cookie-based auth is possible but awkward to configure
  • Cache invalidation can be tricky for frequently updated tiles
  • Excellent performance for read-heavy, public datasets

Alternatives

Resources