Add Guava Response Cache Spring Boot

To add simple response cacheing to a Spring Boot application.


  1. Add the guava dependency.
  2. Configure the cache

    Annotate the config class

    import org.springframework.cache.annotation.EnableCaching;

    Configure the bean

       * Response cache.
      public CacheManager guavaCacheManager() {
        GuavaCacheManager guavaCacheManager = new GuavaCacheManager();
            Long.parseLong(env.getProperty("request.cache.timeout", "600")), TimeUnit.SECONDS));
        return guavaCacheManager;
  3. Annotate cacheable controller methods
    import org.springframework.cache.annotation.Cacheable;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s