Hot deployment of updated (existing) themes

As described in the documentation themes might be “hot deployed” during runtime without downtime.

I have tried this several times and figured out it works perfectly for themes that have not yet been deployed. But when I tried to update an existing theme (having the same name for obvious reasons) it does not override the existing one until I restart Keycloak. Clearing the realm cache also didn’t work.

Am I missing something here?

Thanks in advance!

Did you try with theme cache disabled? In standalone.xml set cacheThemes and cacheTemplates to false, and also set staticMaxAge to -1.

I did want to at some point have theme caches automatically cleared, and also somehow the resource version updated, but never had time to do it.

Thanks for this tip, didn’t know about that and I (or a colleague) will try this.

Is there a feature request or sth like that already our should we create one?

I think there are some, but don’t have time to look for it right now. Feel free to create a new one, then we’ll figure out if it’s a duplicate when we triage it.

keycloak-11.0.2

this issue still exists. theme in system, we deploy new theme file won’t replace or update existing theme. like the cache never gone.

env:

standalone.xml already set

<theme>
                <staticMaxAge>-1</staticMaxAge>
                <cacheThemes>false</cacheThemes>
                <cacheTemplates>false</cacheTemplates>
                <dir>${jboss.home.dir}/themes</dir>
</theme>

And I start server by command: ./bin/standalone.sh --debug

Would please tell us where the cache file located? so we can just delete them?
Thank you.

Just figured out. It’s my problem.

My browser cached theme file before I disable cacheTheme, clear the browser cache data will work out. the hot deployment works just fine.

How would this work in a production environment where

  • you do not want to disable the cache template
  • but you are planning to update your theme

I understand that during development it’s easy to disable the cache, but I assume that in a production environment there should be a way to invalidate the theme cache for a certain realm without restarting the entire keycloak service ?

3 Likes

I second this question. This seems like a very common use-case. How should we do that?

I have investigated the issue in Old theme resources are loaded even after restart due to theme caching and reported a bug ticket.

For now, I remove my Docker-container and create a new one after a hot deployment of the updated theme (my standalone volume is mounted). However, this kills the added value of the hot deployment feature.