The {% cache %} tag

Interested in optimizing your website? Let's take a closer look at our mysterious friend the {% cache %} tag. The {% cache %} tag is quite talented, but can be hard to get to know. We'll take a look at what's happening when we use the {% cache %} tag, explore some of the settings, and discuss alternatives to the {% cache %} tag when it comes to keeping zippy.

Interested in optimizing your website? Let's take a closer look at our mysterious friend the {% cache %} tag. The {% cache %} tag is quite talented, but can be hard to get to know. We'll take a look at what's happening when we use the {% cache %} tag, explore some of the settings, and discuss alternatives to the {% cache %} tag when it comes to keeping zippy.

  • 00:57 - Introduction
  • 05:15 - Exploring how the {% cache %} tag works in the database
  • 05:42 - How Craft stores your cached content. The craft_templatecaches table
  • 08:59 - How Craft updates the cache when you add, edit, and delete content. The craft_templatecacheelements table
  • 12:21 - How Craft tracks queries that happen within the {% cache %} tag. The craft_templatecachecriteria table
  • 15:02 - Clearing the Template Cache
  • 16:02 - Observing page load time, memory, and database queries using the {% cache %} tag with a simple page
  • 19:20 - Observing page load time, memory, and database queries using the {% cache %} tag with a more complex page
  • 24:52 - How many queries is Craft using to load the page?
  • 26:45 - When should we consider caching each individual entry instead of all entries in a query?
  • 33:50 - Caching content as an entry is being saved
  • 35:44 - A few non-standard uses of cache - navigation, random entries
  • 40:06 - A few more comments on using cache on individual entries in a loop
  • 41:23 - Right and wrong ways to use the cache tag
  • 46:49 - Can you alternate the type of cache you are using on different types of content?
  • 49:59 - Can you reduce the number of tasks that need to be run to clear cache when you have lots of entries?
  • 54:12 - A quick nod to a few other types of cache
  • 55:15 - Final comments

Level up in Craft CMS with practical examples, snippets, and patterns.
Craft The Planet emails are sent out several times a week.