From 8a2a92cd3a46eba02f6160d905801f47a3dfceb1 Mon Sep 17 00:00:00 2001 From: TimothyFothergill <67912934+TimothyFothergill@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:24:09 +0100 Subject: [PATCH 1/8] PLATUI-2703 add caching to hmrc-frontend assets --- play-frontend-hmrc-play-30/src/main/resources/reference.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/play-frontend-hmrc-play-30/src/main/resources/reference.conf b/play-frontend-hmrc-play-30/src/main/resources/reference.conf index e1f3f2cf5..59f1c7b43 100644 --- a/play-frontend-hmrc-play-30/src/main/resources/reference.conf +++ b/play-frontend-hmrc-play-30/src/main/resources/reference.conf @@ -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 From 06eb5a9d5ef150a72aaed68437a85fff02f54b31 Mon Sep 17 00:00:00 2001 From: TimothyFothergill <67912934+TimothyFothergill@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:45:37 +0100 Subject: [PATCH 2/8] PLATUI-2703 bump sbt-auto-build --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4f70de4b2..e77c3beb7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,7 +9,7 @@ sys.env.get("PLAY_VERSION") match { case _ => libraryDependencySchemes := libraryDependencySchemes.value // or any empty DslEntry } -addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.21.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") sys.env.get("PLAY_VERSION") match { From 0c610ace9d6fac973646248896d5c58ecc0ffa43 Mon Sep 17 00:00:00 2001 From: TimothyFothergill <67912934+TimothyFothergill@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:11:23 +0100 Subject: [PATCH 3/8] PLATUI-2703 update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f5f93d03..35889e46f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.5.1] - 2024-04-15 + +### Changed + +- Added in caching with a max-age of 60 minutes for hmrc-frontend resources + ## [9.5.0] - 2024-04-3 ### Changed From 22fbd3fdb09b5f73e4c4d65eb298b7146bde24aa Mon Sep 17 00:00:00 2001 From: TimothyFothergill <67912934+TimothyFothergill@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:11:23 +0100 Subject: [PATCH 4/8] PLATUI-2703 update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 442e9ad35..0636262b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From 4f39b8368f253143c040eda32d0041b4f3fb6fc9 Mon Sep 17 00:00:00 2001 From: TimothyFothergill <67912934+TimothyFothergill@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:18:57 +0100 Subject: [PATCH 5/8] PLATUI-2703 update CHANGELOG.md --- CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d00bb8e..0636262b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,12 +26,6 @@ For compatibility information see `govukFrontendVersion` and `hmrcFrontendVersio - [hmrc/hmrc-frontend v6.15.0](https://github.com/hmrc/hmrc-frontend/releases/tag/v6.15.0) - [alphagov/govuk-frontend v5.3.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.3.0) -## [9.5.1] - 2024-04-15 - -### Changed - -- Added in caching with a max-age of 60 minutes for hmrc-frontend resources - ## [9.5.0] - 2024-04-3 ### Changed From 841a3123dae69c5223ba33e90e209a5dbe0094bd Mon Sep 17 00:00:00 2001 From: TimothyFothergill <67912934+TimothyFothergill@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:24:46 +0100 Subject: [PATCH 6/8] PLATUI-2703 add test for cache-control headers --- .../uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala b/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala index 37a3b658e..91a287f3b 100644 --- a/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala +++ b/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala @@ -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 @@ -38,5 +39,10 @@ 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 { + header("Cache-Control", route(app, FakeRequest("GET", "/assets/all.js")).get).get must include ("max-age=3600") + } + } } From 02818f477cdc02b3521b09f7b5dd10bb6664ca6a Mon Sep 17 00:00:00 2001 From: TimothyFothergill <67912934+TimothyFothergill@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:44:34 +0100 Subject: [PATCH 7/8] PLATUI-2703 refactor cache-control headers test --- .../uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala b/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala index 91a287f3b..3d40ab9d2 100644 --- a/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala +++ b/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala @@ -41,7 +41,13 @@ class AssetsSpec extends AnyWordSpec with Matchers with Results with GuiceOneApp } "Asset controller " must { "serve assets with correct cache-control headers" in { - header("Cache-Control", route(app, FakeRequest("GET", "/assets/all.js")).get).get must include ("max-age=3600") + 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") + } } } From d60e3675454da5cba8150e0024e41f4d7558d2be Mon Sep 17 00:00:00 2001 From: TimothyFothergill <67912934+TimothyFothergill@users.noreply.github.com> Date: Fri, 19 Apr 2024 07:58:47 +0100 Subject: [PATCH 8/8] PLATUI-2703 further refactor of cache-control header test --- .../uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala b/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala index 3d40ab9d2..dad4bba11 100644 --- a/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala +++ b/it-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/controllers/AssetsSpec.scala @@ -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. @@ -47,7 +47,7 @@ class AssetsSpec extends AnyWordSpec with Matchers with Results with GuiceOneApp headerValue must include("max-age=3600") case None => fail("Cache-Control header not found") - } + } } }