Skip to content

Commit

Permalink
Merge pull request #296 from hmrc/PLATUI-2703
Browse files Browse the repository at this point in the history
PLATUI-2703 add caching to hmrc-frontend assets
  • Loading branch information
TimothyFothergill committed Apr 19, 2024
2 parents 4eee1ee + d60e367 commit 57a2517
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
For compatibility information see `govukFrontendVersion` and `hmrcFrontendVersion` in
[LibDependencies](project/LibDependencies.scala)

## [9.6.1] - 2024-04-15

### Changed

- Added in caching with a max-age of 60 minutes for hmrc-frontend resources

## [9.6.0] - 2024-04-10

### Changed
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@ package uk.gov.hmrc.hmrcfrontend.controllers

import org.scalatest.TestData
import org.scalatest.matchers.must.Matchers
import org.scalatest.matchers._
import org.scalatest.wordspec.AnyWordSpec
import org.scalatestplus.play.guice.GuiceOneAppPerTest
import play.api.Application
Expand All @@ -38,5 +39,16 @@ class AssetsSpec extends AnyWordSpec with Matchers with Results with GuiceOneApp
status(route(app, FakeRequest("GET", "/assets/all.js")).get) must be(200)
}
}
"Asset controller " must {
"serve assets with correct cache-control headers" in {
val cacheControlHeader = header("Cache-Control", route(app, FakeRequest("GET", "/assets/all.js")).get)
cacheControlHeader match {
case Some(headerValue) =>
headerValue must include("max-age=3600")
case None =>
fail("Cache-Control header not found")
}
}
}

}
3 changes: 3 additions & 0 deletions play-frontend-hmrc-play-30/src/main/resources/reference.conf
Expand Up @@ -82,6 +82,9 @@ pta-account-menu {

language.fallback.url = "https://www.gov.uk/government/organisations/hm-revenue-customs"

# Cache set to 60 minutes for hmrc-frontend assets
play.assets.cache."/public/lib/hmrc-frontend/"="public, max-age=3600"

# used to enable A/B testing experiments from the experimentation team
optimizely.url = "https://cdn.optimizely.com/js/"
optimizely.projectId = null

0 comments on commit 57a2517

Please sign in to comment.