liveBook · Manning

Template caching

As explained in Spring in Action, Sixth Edition

Template caching stores parsed or processed templates so they do not need to be reparsed for every request.

Template caching stores parsed or processed templates so they do not need to be reparsed for every request. In Spring Boot, each supported template engine exposes a cache property that can be enabled or disabled. section 2.5.1

Use these approaches when configuring template caching:

  • Disable caching during development by setting the selected engine’s cache property to false. section 2.5.1
  • For Thymeleaf, add spring.thymeleaf.cache=false to application.properties. section 2.5.1
  • Remove the false setting or change it to true before production deployment; alternatively, let Spring Boot DevTools disable template caches during development and reenable them when DevTools disables itself in production. section 1.3.5 section 2.5.1
Table 2.3 Properties to enable/disable template caching (view table figure)

Template

Cache-enable property

FreeMarker

spring.freemarker.cache

Groovy templates

spring.groovy.template.cache

Mustache

spring.mustache.cache

Thymeleaf

spring.thymeleaf.cache

Compare the cache-enable properties for FreeMarker, Groovy templates, Mustache, and Thymeleaf. section 2.5.1

How Spring in Action, Sixth Edition covers it

How deep it goes
Defines engine-specific properties and deployment behavior but stops short of explaining cache implementation internals.
Examples
Uses spring.thymeleaf.cache=false and compares cache properties for FreeMarker, Groovy templates, Mustache, and Thymeleaf.
What it assumes
Assumes a Spring Boot application using a supported template engine and teaches cache toggling through configuration.
What you can do after
Operate/configure template caching through engine properties or Spring Boot DevTools.
How it connects
Connects template engines with Spring Boot DevTools, application properties, and profiles.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.