We are using Spring's Caching abstraction to add caching behaviour to our services.
By default, @Enablecaching annotation either enables/disables caching for entire service.
The @Cacheable annotation has been used on all methods.
But, now we want to enable caching for some endpoints/methods and disable caching for other endpoints
Is there a way to achieve that with removing the added annotations in the service something like an Interceptor/Filter vetoing the caching behaviour for certain methods based on configuration.
One work around for this You can make your method conditional for cache on the base of parameter. The cache annotations support such functionality through the condition parameter which takes a SpEL expression that is evaluated to either true or false.
As explained in documentation. https://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html