Skip to content

Make RenderTemplate arguments transient for serialization-based caches#1559

Open
megamattron wants to merge 1 commit intoplayframework:masterfrom
larvalabs:gh-1558-transient-render-template
Open

Make RenderTemplate arguments transient for serialization-based caches#1559
megamattron wants to merge 1 commit intoplayframework:masterfrom
larvalabs:gh-1558-transient-render-template

Conversation

@megamattron
Copy link

@megamattron megamattron commented Mar 1, 2026

Marks the arguments field in RenderTemplate as transient so that @CacheFor works with serialization-based cache backends (Redis, Memcached).

The arguments map often contains non-serializable objects, causing serialization failures when Cache.set() is called in ActionInvoker. This is safe because by construction time the template is already rendered into the content field, and apply() only uses content and name.

I have been using this change in production for several years to cache fully rendered output on heavy pages.

Fixes #1558

…alization-based caches

When using @CacheFor with Redis or Memcached, RenderTemplate objects
fail to serialize because the arguments map often contains
non-serializable objects. Since the template is already rendered into
the content field by construction time, and apply() only uses content
and name, the arguments field is safely marked transient.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RenderTemplate cannot be serialized for caching with Redis/Memcached

1 participant