alainlompo
alainlompo

Reputation: 4434

Spring CacheManager vs ETag

I have a Spring (not Boot) application with a successfully configured and used Caching mechanism through the CacheManager that looks like the following:

@Configuration
@EnableCaching(proxyTargetClass=true)
public class CachingConfig {
   @Bean
   public CacheManager cacheManager() {
      SimpleCacheManager cacheManager = new SimpleCacheManager();
      List<Cache> caches = List.of(
         new ConcurrentMapCache("cache_name_1"),
         // ....
      );
      
      cacheManager.setCaches(caches);
      return cacheManager;
   }

}

Spring also supports ETags as can be read here. And it could be configured as follows:

@Bean
public ShallowEtagHeaderFilter shallowEtagHeaderFilter() {
    return new ShallowEtagHeaderFilter();
}

Is there any need for ETags when one has already configured Caching used the first approach above?

Upvotes: 0

Views: 229

Answers (1)

Bill Mair
Bill Mair

Reputation: 1151

You have 2 different concepts.

Server side cache: Calls from different clients with the same parameters can get the same result from server cache.

Client side cache: Get once and use ETag to see if anything has changed, no need to get it again if not modified.

Upvotes: 0

Related Questions