Spring Saving Data - Caching

How to enable caching using Spring Data Rest?

The reason is that the list and methods of the repository will not change after the application runs. In addition, if the data underlying the rest of the API is changed only through the break API, it also makes it possible to cache data.

I believe that caching at some level occurs in the REST API, and it would be ideal if caching occurred at the final response stage, i.e. json response (to avoid the overhead of sorting objects in json)

Thoughts / comments?

+4
source share
1 answer

The easiest way to implement this at the repository level is to use Spring @Cacheable as seen in the Spring Data JPA sample project .

Another option is to use HTTP caching using the Apache HTTPD or Varnish settings, for example.

+5
source

Source: https://habr.com/ru/post/954068/


All Articles