View a markdown version of this page

Caching strategy - Dynamic Image Transformation for Amazon CloudFront

Caching strategy

The ECS architecture implements a multi-layer caching strategy to optimize performance and reduce latency.

In-memory cache

  • Each ECS task maintains local caches for transformation policies and origin mappings

  • Cache is populated during task startup from DynamoDB

  • Fast lookup times for frequently accessed configurations

Cache initialization

  1. New ECS tasks query DynamoDB during startup

  2. All transformation policies are loaded into memory

  3. Origin mappings are stored in optimized data structures

Cache invalidation

  • Rolling deployment strategy updates all ECS tasks with new configurations

  • Eventual consistency model balances performance with data freshness

  • Cache refresh typically takes up to 5 minutes

Cache consistency

  • New ECS tasks always load the latest configuration data

  • Existing tasks maintain cached data until manual refresh or natural replacement

  • Auto-scaling events automatically provision tasks with current data

  • Stale cache scenarios are resolved through the rolling update process