Cache Infrastructure

Details about how your images are cached by Gumlet

We have created a multi-level caching infrastructure to ensure that images are delivered as fast as possible.

This also minimizes the cost of fetching the image from the origin and processing it again.

Origin Cache

As the name suggests, this cache keeps original images cached. There is no additional cost for this cache and it's always enabled for everyone using Gumlet.

Type

This cache is an LRU cache with an eviction time of 90 days. It means that if the file was not used in the last 90 days for any transformations, we will delete the file from our cache.

Behaviour

Origin cache respects all the Cache-Control, ETag and Last-Modified headers from your origin server. It re-validates the cache in case it's expired using the appropriate If-Modified-Since and If-None-Match headers.

Advantages

This cache ensures that Gumlet does not frequently access origin server. Even when the re-validation is done, appropriate headers are sent to ensure that minimal data transfer is done. It helps minimise the cost of accessing origins especially for Amazon S3 which charges users based on number of requests and per GB data transferred.

Processed Cache

All processed images are cached by us to ensure that any repeat request for same image is served as fast as possible without any delays. There is no additional cost for this cache and it's always enabled for everyone using Gumlet.

Type

This cache expiration time is 6 months. Any processed file is cached for that duration and then evicted.

Behaviour

This cache works the same way a reverse proxy like NGINX would perform the cache. It respects all HTTP cache headers.

Advantages

CDNs generally don't keep each file cached for the duration specified in cache-control headers. They generally evict the caches based on the LRU mechanism. It results in cache hit ratios lower than 100%. We typically see the cache hit ratios of about 90%. This means that even if the image was already processed, CDNs will evict 10% of the cache due to infrequent access.

Our processed cache infrastructure keeps all those images cached so that requests made by clients are served super fast.

CDN Cache

Our CDN provider CloudFront also performs cache on their end. The cache performed by them is according to the s-maxage parameter provided in the Cache-Contorl header. We currently set it at 180 days. CloudFront decides cache behavior and eviction policy for this cache.