CachingDirectives

Use these directives to “wrap” expensive operations with a caching layer that runs the wrapped operation only once and returns the the cached value for all future accesses for the same key (as long as the respective entry has not expired). See caching for an introduction to how the caching support works.

To enable caching support add a library dependency onto:

sbt
libraryDependencies += "com.typesafe.akka" %% "akka-http-caching" % "10.0.15"
Gradle
dependencies {
  compile group: 'com.typesafe.akka', name: 'akka-http-caching_2.12', version: '10.0.15'
}
Maven
<dependency>
  <groupId>com.typesafe.akka</groupId>
  <artifactId>akka-http-caching_2.12</artifactId>
  <version>10.0.15</version>
</dependency>

Directives are available by importing:

Scala
import akka.http.scaladsl.server.directives.CachingDirectives._
Java
import static akka.http.javadsl.server.directives.CachingDirectives.*;
The source code for this page can be found here.