keycloak / keycloak

Open Source Identity and Access Management For Modern Applications and Services
https://www.keycloak.org
Apache License 2.0
23.76k stars 6.82k forks source link

Provide a way to clear theme cache without restarting keycloak #23503

Open marconett opened 1 year ago

marconett commented 1 year ago

Description

Currently, to deploy a change to a freemarker theme or theme message (.properties files), you have to restart the keycloak server which results in unnecessary downtime.

Adding a simple "Clear theme cache" button (for example on the Client details -> Settings view) would go a long way.

There's two common answers to this problem:

Disabling theme caching

Making small changes to the theme from time to time doesn't warrant disabling caching completely. Caching is there for a reason and disabling it obviously impacts page load times and compute resource usage.

According to the docs: Be sure to re-enable caching in production as it will significantly impact performance. (https://www.keycloak.org/docs/latest/server_development/#creating-a-theme)

Deleting cache manually

Deleting the contents of keycloak/data/tmp/kc-gzip-cache only clears cached resources (js, css, images, etc.). It doesn't work for freemarker templates or messages.

Furthermore, not every theme developer has or should have SSH access and the ability to delete files on a production system.

Discussion

No response

Motivation

No response

Details

No response

RobIsHere commented 4 months ago

Some "start --clear-cache" that starts keycloak with a clear cache would be great. In Docker Scenarios you usually just reload your container after installing a new e.g. themes.jar. With that command every start could be a fresh start reflecting the status quo at startup time like you would expect it from a usual program.

Could starting with cleared cache even be the default? As it is totally unusual that a program caches things across program restarts - there are not many with this behavior, this behavior should be documented IMHO so people are not surprised by updates that simply don't appear and things like this.