Skip to content

Respect HTTP caching headers for tile requests #124

@dougborg

Description

@dougborg

Context

The OSM tile usage policy requires:

  1. Cache tiles locally per HTTP caching headers (Cache-Control, Expires, ETag) with a minimum 7-day fallback when headers aren't present
  2. Use conditional requests (If-None-Match, If-Modified-Since) for expired tiles to avoid re-downloading unchanged tiles
  3. Never send Cache-Control: no-cache or similar bypass directives (we're compliant here — we don't send these)

Current behavior

  • tiles_from_remote.dart fetches tiles with a plain GET and only checks the status code — response caching headers are ignored entirely
  • No persistent tile cache with TTL tracking exists (flutter_map's in-memory cache evicts on map rebuild)
  • Expired tiles are re-fetched unconditionally (no ETag/304 flow)

Expected behavior

  • Parse Cache-Control / Expires from tile responses and store tiles on disk with expiration metadata
  • Default to 7-day cache when response headers are absent
  • On cache expiry, send conditional requests (If-None-Match / If-Modified-Since) and handle 304 Not Modified

Notes

This applies to all tile servers the app talks to, not just tile.openstreetmap.org.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: dataData architecture, caching, and storagearea: mapMap rendering, tiles, and layersenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions