Shopify / response_bank

Simple response caching for Ruby applications
http://www.shopify.com
MIT License
135 stars 18 forks source link

Collapse cache entry to single key #67

Closed colinbendell closed 1 year ago

colinbendell commented 1 year ago

Previously a cache miss would be cached twice - an unversioned entry + a versioned entry for the same cache key. This would allow cases where the versioned entry was not strictly needed and shouldn't cause a cache miss (eg: bot traffic). However, this doubling of the cache entries reduces the effective memory footprint and requires multiple round trips to the backing cache.

This PR collapses the cache to a single key and uses the entity-tag (etag) value for the situations when a strict cache value needs to be evaluated. This reduces the number of queries to the cache while preserving the intended semantics of the cache.

Additionally, we move the a limited header set into the cache. Header caching is required for response metadata caching and will support other use cases such as the use of cache-tags and other cache-control header values.

Other changes in this pr:

Future work should include: