Changes made to Thymeleaf HTML template not reflected on browser refresh

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Changes made to Thymeleaf HTML template not reflected on browser refresh

Alex
Hi,

When I took the sample thymeleaf vs jsp sample app for a spin I noticed the above problem.
The jsp template has no problem, all the changes are picked on browser refresh.
Is there a way to solve this issue?

To verify this issue, just edit this line in subscribeth.html

             

This is a Thymeleaf template

Reply | Threaded
Open this post in threaded view
|

Re: Changes made to Thymeleaf HTML template not reflected on browser refresh

Alex
Please note that this happens when running the app inside Tomcat.
Reply | Threaded
Open this post in threaded view
|

Re: Changes made to Thymeleaf HTML template not reflected on browser refresh

danielfernandez
Administrator
In reply to this post by Alex

This is because Thymeleaf has a parsed template cache which is active by default, so it is not reading your template from disk every time you refresh your page on the browser. JSP doesn't have this cache - instead tomcat detects every modification you do on your JSP and recompiles its corresponding servlet when such modification occurs.

If you want your template file to be read every time from disk, you have several options:

1. Disable the cache setting its size to 0.
2. Set the TTL for your template (at the template resolver) to 0ms.
3. Set your specific template as non-cacheable (at the template resolver, too).

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: Changes made to Thymeleaf HTML template not reflected on browser refresh

Alex
Thanks dfernandez.

I think this should be noted in the documentation.
Reply | Threaded
Open this post in threaded view
|

Re: Changes made to Thymeleaf HTML template not reflected on browser refresh

danielfernandez
Administrator
Alex wrote
I think this should be noted in the documentation.
Absolutely. If you need more detail about how this parsed template cache works, chapter 15 in the "Using Thymeleaf" tutorial is entirely devoted to it.

Regards,
Daniel.