Closed mmoayyed closed 8 years ago
The cache is managed by the TemplateResolver
created in the same auto-configuration class.
Did you run in an actual problem? From your description, it's not really clear if you're guessing or you're actually having a problem.
I did run into a problem. I am not sure if what I am doing is purely incorrect and can be done in a better way, but here is what I have as a sample:
ThymeleafViewResolver
ThymeleafViewResolver
autowired in as field, via boot. So, what in order to correctly initialize A as a resolver, I added a PostConstruct method to A to set fields, based on the autowired ThymeleafViewResolver
. This allows me to set the template engine and locale and a bunch of other settings on A, that were autowired from the actual ThymeleafViewResolver instance.
This presented the problem/bug, where views seemed always cached by the resolver because ThymeleafViewResolver.isCached() always returned true, and the ThymeleafViewResolver .getCacheLimit() was always > 0.
What I can see is that you are using a customization of the view resolver and that use cases works fine without the customization. If you want us to look into it, we need a way to make the link between the customization and the issue you're experiencing. Can you share a sample that exhibits the problem?
Happy to remove it, if I can.
Here is the code: https://github.com/Unicon/cas/blob/letsboot/cas-server-webapp-themes/src/main/java/org/jasig/cas/services/web/RegisteredServiceThemeBasedViewResolver.java
Also, perhaps a related yet different issue is boot does not allow me to create something like this: https://github.com/Unicon/cas/blob/letsboot/cas-server-webapp-config/src/main/java/org/jasig/cas/config/CasProtocolViewsConfiguration.java#L212
Which I have had to do in order to compress whitespace that is left by thymeleaf. It would be best actually if boot could do this automatically for me, via a prop, etc.
In the first link, this is the bit that does the job:
setCache(this.properties.isCache());
if (!isCache()) {
setCacheLimit(0);
}
I think not setting the cache property on ThymeleafViewResolver
is probably a bug, we do it for all other template auto-configurations.
Indeed, we do it for the ThymeleafResolver
but it looks like we forgot to do it for ThymeleafViewResolver
.
We don't have a property for cache limit, so I'm only going to apply the spring.thymeleaf.cache
property to the auto-configured ThymeleafViewResolver
.
The auto configuration for the ThymeleafViewResolver does:
The resolver also has setters for cache and cachelimit which are not taken into account from the properties. The resolver as such always ends up caching views, it seems.