Cache bonanzaHarald Schult Ulriksen
@hsulriksenhttp://aurum.no
HTTP Cache Output cache
Application cache
RFC 7234 - HTTP/1.1 Caching
RFC 7234 - HTTP/1.1 Caching
A stored response can be considered fresh if the response can be reused without validation
RFC 7234 - HTTP/1.1 CachingAlthough caching is an entirely OPTIONAL feature of HTTP, it can be assumed that reusing a cached response is desirable and that such reuse is the default behavior when no requirement or local configuration prevents it. Therefore, HTTP cache requirements are focused on preventing a cache from either storing a non-reusable response or reusing a stored response inappropriately, rather than mandating that caches always store and reuse particular responses.
RFC 7234 - HTTP/1.1 CachingFreshness
• s-max-age• max age• expires• heuristics
RFC 7234 - HTTP/1.1 CachingFreshness
• s-max-age• max age• expires• heuristics
Last modified Last requested Now
Tid
RFC 7234 - HTTP/1.1 CachingFreshness
• s-max-age• max age• expires• heuristics
Validation - RFC 7232
• Etag• Last-Modified
• If-none-match• If-modified-since
RFC 7234 - HTTP/1.1 CachingLinker
• RFC 7234 - https://tools.ietf.org/html/rfc7234• RFC 7232 - https://tools.ietf.org/html/rfc7234• Mark Nottinham - https://www.mnot.net/cache_docs• Darrel Miller - http://
bizcoder.com/caching-is-hard-draw-me-a-picture• Jesse Wilson – https://
publicobject.com/2015/03/26/how-do-http-caching-heuristics-work
Application cache• Local cache• Redis • Redis with msgpack•Distributed layered cache•With synchronization• Fun with Redis
Local cache
Demo
Remote cache
Remote cache
Remote cache
Redis• http://redis.io• Key value store + data structures• By Salvatore Sanfilippo / @antirez• Ansi C• Single threaded• Lua in server• Microsoft research port to windows – nuget redis-64• On Azure, AWS og Google cloud.
Demo
In production
Layered distributed cacheApplication Local cache Remote cache Slow thing
Demo
Pub-sub12
3
4
1.Store data 2.Send publish notification3.Publish notification4.Get data
Demo
In production
In production
Other datastructures in RedisSearch for «An introduction to data types and abstractions»
• Key/Value• Lists• Hashsets• Set• Sorted set• Hyperloglog• Geospatial
Lua scriptAtomisk operasjon. Ingen rollback. Kan lastes opp til server og kalles basert på hash.
Add now-playing
Read
Top Related