# Getting the most out of Varnish --- # Basics * Reverse HTTP caching proxy * Load balancing * High performance * No SSL * Avoids "Thundering herd" * Caching logic in VCL --- # Setup --- # Configure sane resource limits * cache memory * thread_pools * thread_pool_min, thread_pool_max --- # Caching logic --- # vcl_recv * Normalize and rewrite client input * Pick a backend web server * Decide caching policy * Access control --- # Enable grace mode --- # Drop unnecessary cookies  --- # Force pass for sensitive URLs --- # vcl_hash * Defines what is unique about a request. * Executed directly after `vcl_recv` --- # Do not Vary on User-Agent --- # vcl_hit * Right after an object has been found (hit) in the cache * You can change the TTL or issue purge * Often used to throw out an old object --- # vcl_miss * Right after an object was looked up and not found in cache * Mostly used to issue purge * Can also be used to modify backend request headers --- # vcl_pass * Run after a pass in `vcl_recv` or after a lookup that returned a hitpass * Not run after `vcl_fetch` --- # vcl_fetch * Sanitize server response * Override cache duration --- # Understand hit\_for_pass --- # vcl_deliver * Common last exit point for all (except `vcl_pipe`) code paths * Often used to add and remove debug-headers --- # Application --- # Use Far Future Expiration --- # Operation --- # Monitor KPI * cache_hit * cache_miss * backend_fail * backend_toolate * lru_nuked --- # Monitor syslog --- # Questions? --- # Thanks! * [Sad Cookie by Hey Paul Studios, on Flickr](https://www.flickr.com/photos/hey__paul/5641965159)