Skip to content

Commit

Permalink
Set timestamp in output jars from SBT
Browse files Browse the repository at this point in the history
Since SBT 1.4.0, SBT has edited the last modified dates in packaged
JARs, which include web assets (css, js, etc.); Grid's current version
sets the date to 1 Jan 2010. Play framework uses these dates to
calculate the ETag and Last-Modified headers. Since the headers are now
based upon a static date, caching (especially via Cloudfront) is broken,
returning outdated assets.

This commit restores the previous behaviour, so cloudfront should now
notice and pick up new assets upon deployment.

See also <playframework/playframework#10572>
See also <sbt/sbt#6237>
  • Loading branch information
andrew-nowak committed Jan 17, 2022
1 parent cfa47a3 commit 79a8947
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ resolvers ++= Seq(

PlayKeys.devSettings := Seq("play.akka.dev-mode.akka.http.parsing.max-uri-length" -> "20480")

// We need to keep the timestamps to allow caching headers to work as expected on assets.
// The below should work, but some problem in one of the plugins (possible the play plugin? or sbt-web?) causes
// the option not to be passed correctly
// ThisBuild / packageTimestamp := Package.keepTimestamps
// Setting as a packageOption seems to bypass that problem, wherever it lies
import sbt.Package.FixedTimestamp
ThisBuild / packageOptions += FixedTimestamp(Package.keepTimestamps)

libraryDependencies ++= Seq(
ws,
filters,
Expand Down

0 comments on commit 79a8947

Please sign in to comment.