From 61bb0249a418039306688545eb1bab604ab1b16f Mon Sep 17 00:00:00 2001 From: Andrew Nowak <10963046+andrew-nowak@users.noreply.github.com> Date: Tue, 14 Nov 2023 17:20:46 +0000 Subject: [PATCH 1/2] Set printable crossword cache time to 60 secs Occasionally we needed to update the crossword data after publication. This happened recently, and while the interactive/playable crossword was very fast to update, we received some comments (https://www.theguardian.com/crosswords/cryptic/29227#comment-165327727, and others) that the `/print` version remained out of date. I was able to request a cache purge for the page to correct it in this circumstance, but it would be preferable if the cache time was sufficiently short that updates propagated quickly without intervention. --- applications/app/controllers/CrosswordsController.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/app/controllers/CrosswordsController.scala b/applications/app/controllers/CrosswordsController.scala index aa7ad365b69..9c01529c3b7 100644 --- a/applications/app/controllers/CrosswordsController.scala +++ b/applications/app/controllers/CrosswordsController.scala @@ -107,7 +107,7 @@ class CrosswordPageController(val contentApiClient: ContentApiClient, val contro def printableCrossword(crosswordType: String, id: Int): Action[AnyContent] = Action.async { implicit request => withCrossword(crosswordType, id) { (crossword, content) => - Cached(3.days)( + Cached(60)( RevalidatableResult.Ok( PrintableCrosswordHtmlPage.html( CrosswordPageWithSvg( From f57dea29afaad81d4f77660fc2d7e6fa78a96c16 Mon Sep 17 00:00:00 2001 From: Andrew Nowak Date: Tue, 14 Nov 2023 20:53:17 +0000 Subject: [PATCH 2/2] make cache duration units explicit in crossword controller --- applications/app/controllers/CrosswordsController.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/app/controllers/CrosswordsController.scala b/applications/app/controllers/CrosswordsController.scala index 9c01529c3b7..b2561b234f3 100644 --- a/applications/app/controllers/CrosswordsController.scala +++ b/applications/app/controllers/CrosswordsController.scala @@ -58,7 +58,7 @@ trait CrosswordController extends BaseController with GuLogging with ImplicitCon context: ApplicationContext, ): Future[Result] = { withCrossword(crosswordType, id) { (crossword, content) => - Cached(60)( + Cached(60.seconds)( RevalidatableResult.Ok( CrosswordHtmlPage.html( CrosswordPageWithSvg( @@ -87,7 +87,7 @@ class CrosswordPageController(val contentApiClient: ContentApiClient, val contro def accessibleCrossword(crosswordType: String, id: Int): Action[AnyContent] = Action.async { implicit request => withCrossword(crosswordType, id) { (crossword, content) => - Cached(60)( + Cached(60.seconds)( RevalidatableResult.Ok( CrosswordHtmlPage.html( AccessibleCrosswordPage( @@ -107,7 +107,7 @@ class CrosswordPageController(val contentApiClient: ContentApiClient, val contro def printableCrossword(crosswordType: String, id: Int): Action[AnyContent] = Action.async { implicit request => withCrossword(crosswordType, id) { (crossword, content) => - Cached(60)( + Cached(60.seconds)( RevalidatableResult.Ok( PrintableCrosswordHtmlPage.html( CrosswordPageWithSvg( @@ -127,7 +127,7 @@ class CrosswordPageController(val contentApiClient: ContentApiClient, val contro val globalStylesheet = Static(s"stylesheets/$ContentCSSFile.css") - Cached(60) { + Cached(60.seconds) { val body = s"""$xml""" RevalidatableResult( Cors {