aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/core/rest/DriverRoute.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/core/rest/DriverRoute.scala')
-rw-r--r--src/main/scala/xyz/driver/core/rest/DriverRoute.scala20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main/scala/xyz/driver/core/rest/DriverRoute.scala b/src/main/scala/xyz/driver/core/rest/DriverRoute.scala
index 288245a..911e306 100644
--- a/src/main/scala/xyz/driver/core/rest/DriverRoute.scala
+++ b/src/main/scala/xyz/driver/core/rest/DriverRoute.scala
@@ -2,8 +2,9 @@ package xyz.driver.core.rest
import java.sql.SQLException
-import akka.http.scaladsl.model.{StatusCodes, _}
+import akka.http.scaladsl.model.headers.CacheDirectives.`no-cache`
import akka.http.scaladsl.model.headers._
+import akka.http.scaladsl.model.{StatusCodes, _}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server._
import com.typesafe.scalalogging.Logger
@@ -32,11 +33,7 @@ trait DriverRoute {
val tracingHeader = RawHeader(ContextHeaders.TrackingIdHeader, trackingId)
MDC.put("trackingId", trackingId)
- // This header will eliminate the risk of LB trying to reuse a connection
- // that already timed out on the server side by completely rejecting keep-alive
- val rejectKeepAlive = Connection("close")
-
- respondWithHeaders(tracingHeader, rejectKeepAlive)
+ respondWithHeaders(tracingHeader +: DriverRoute.DefaultHeaders: _*)
}
}
@@ -112,3 +109,14 @@ trait DriverRoute {
}
}
+
+object DriverRoute {
+ val DefaultHeaders: List[HttpHeader] = List(
+ // This header will eliminate the risk of envoy trying to reuse a connection
+ // that already timed out on the server side by completely rejecting keep-alive
+ Connection("close"),
+ // These 2 headers are the simplest way to prevent IE from caching GET requests
+ RawHeader("Pragma", "no-cache"),
+ `Cache-Control`(List(`no-cache`(Nil)))
+ )
+}