data stored somewhere (HDD, DB, Cloud) • I access that data often • Move data closer to where I am • Move data to faster storage ! • Side effect: Reduce load on original storage location
O(1) - stores object, calls prune( ) (if cache is full) • get(key) - O(1) - returns object, moves it to the “head” of the cache • prune( ) - removes object from “tail” of the cache
easy! The Asset Pipeline builds links with the asset_host ! Rails: # config/environments/production.rb config.action_controller.asset_host = “mycdn.coolcdn.com” ! Sinatra: (with something like sinatra_asset_pipeline) # in app.rb set :assets_host, ‘mycdn.coolcdn.com’
to prevent caches from interfering with the request or response • Override the default caching algorithm • Specify what can be cached • Specify how long to cache
priority over Cache-Control • Surrogate will cache for 1 year • Browser will cache for 30 minutes • Sometimes Surrogate-Control is stripped by the Surrogate
Keep-Alive • TCP Session is kept open for an extended period • Eliminate costly TCP Handshake • In CDN Land edge nodes may keep connections alive with origin => faster cache misses (Dynamic Site Acceleration)
globally in < 300ms on 95th percentile • Enables dynamic content caching at the edge brucespang.com/bimodal www.fastly.com/blog/building-fast-and-reliable-purging-system
1. Extend models with surrogate key instance methods 2. Add ActionController helpers to set up headers 3. Add purge/purge_all instance methods to models
1. Extend models with surrogate key instance methods 2. Add ActionController helpers to set up headers 3. Add purge/purge_all instance methods to models