Caching Strategies for Scaling Drupal Common Missteps vs Best Practices Corey Wood Senior Technical Account Manager
Apr 14, 2017
Caching Strategies for Scaling DrupalCommon Missteps vs Best Practices
Corey WoodSenior Technical Account Manager
Who?Corey WoodSenior Technical Account Manager, Team Lead
→ Drupalist since 2006 - Drupal 4.7→ Acquia Certified Developer→ Certified ScrumMaster→ Gold medal winning homebrewer→ Industry Experience:
▪ Publishing▪ Advertising▪ Higher Education▪ Public Sector▪ Craft Brewing
What?Caching→ When, where, why, and how Drupal cache works→ When, where, why, and how Drupal cache doesn’t work→ Best practices
▪ Cache invalidation▪ TTL management
→ Common missteps▪ Invalidation, purging, and warming
→ D7 and D8 differences→ Leveraging external proxy cache
Never do the same work twice
The Importance of Proper CachingThe Basics
→ Anatomy of a page request
→ Know your limitations▪ PHP processes▪ MySQL connections▪ CPU usage
→ Never do the same work twice…▪ ...whenever possible
→ What should we cache, and for how long?▪ Everything? ▪ Forever?
Caching in Drupal 7
→ “Clear all caches”→ Cache pages for anonymous users→ Cache blocks→ Minimum cache lifetime→ Expiration of cached pages→ CSS and JS aggregation
Caching in Drupal 8
→ “Clear all caches”→ Cache pages for anonymous users→ Cache blocks→ Minimum cache lifetime→ Page cache maximum age→ CSS and JS aggregation
What’s New in Drupal 8
→ Cache tags▪ More granular control over cache invalidation
→ Cache Context API▪ You can now cache more variants based off of a context (url, user, language, cookie,
etc)→ #post_render_cache
▪ Similar to Edge Side Includes, allows for dynamic elements in cached objects→ Much more
▪ CSS/JS aggregation on by default▪ JS loaded from the bottom▪ Block Cache API removed in favor of render caching
Moving Cache Outside of DrupalMemcache
→ Move Drupal’s cache from the database to memory
Varnish→ Add a reverse proxy caching layer in front of your application to handle larger numbers of
requests.
Content Delivery Network→ An additional layer of distributed reverse proxy cache providing greater scalability and
protection
There are only two hard things in Computer Science: cache invalidation and naming things.
Invalidating, Purging, and WarmingInvalidating cache
→ Minimum cache lifetime in D7→ Using Rules and the Expire module
Purging cache→ The contrib Purge module is your friend→ drush cc all
Warming cache→ The order in which caches are cleared is very important→ Drupal -> Proxy
Thank You