vigamage
vigamage

Reputation: 2115

Thymeleaf - load meta data once and use across all pages

I am developing an ad listing web app using thymeleaf and Spring boot. There I have a basic listing page as the index page and on top of it, there is a search bar. Search bar contains dropdowns for area and category. Those dropdowns are loaded from the meta data that are retrieved from the back end.

Now, once an ad is clicked, the user is redirected to the ad details page. In that page also, I need to have the aforementioned search bar.

The question is, Do I have to load the categories and areas meta data again from the back end when the page redirection take place? Or is there a way to use already fetched data in thymeleaf?

Note that, I am using a fragment as the search bar since it is used in both the pages mentioned above.

Upvotes: 0

Views: 257

Answers (1)

Giuseppe B
Giuseppe B

Reputation: 1294

Not sure what you mean as "backend", as thymeleaf renders the page on the backend and returns it to the client (aka browser). Page is NOT rendered on the client. If you want to avoid to access the application model (as database or network resource) you can just cache the data in your repository class.

some documentation on https://spring.io/guides/gs/caching/

Hope it helps. -G

Upvotes: 1

Related Questions