spring-projects / spring-projects/spring-boot

Support mustache template caching

Open
#20,706 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

According to the JMustache docs, all the necessary classes are thread safe with the caveat that if you customize any classes they also have to be thread safe.

Currently instances of the MustacheView class can be cached, but not the result of compilation. Every time the view is rendered in renderMergedTemplateModel, the resource gets loaded, parsed and compiled into a Template before rendering. If there was an option to cache the compiled form, perhaps with a pluggable caching implementation, we wouldn't need to load and compile on every request. Admittedly I didn't do any performance testing, but it seems like it should be beneficial.

While I'm on the subject of the MustacheView class, it strikes me as odd that it uses a getApplicationContext().getResource(...) to get the resource instead of a MustacheResourceTemplateLoader instance. After all, when using partials, it will load the partial using the MustacheResourceTemplateLoader.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in MustacheView, especially renderMergedTemplateModel, to trace where the resource is loaded, parsed, and compiled on each render. Compare that path with MustacheResourceTemplateLoader and its partial loading behavior. Done means a defined option for caching compiled templates, potentially with a pluggable cache, and a resolved approach for resource loading.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.