From 9a070c7b3fc6f3c8867f3bfec0ce22775cdd6354 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Thu, 12 Sep 2019 17:48:09 -0400 Subject: [PATCH] cache i18n strings --- controller/action/i18nActions.class.php | 7 +++++-- view/Response.class.php | 5 ----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/controller/action/i18nActions.class.php b/controller/action/i18nActions.class.php index dfd490a1..3fd063ee 100644 --- a/controller/action/i18nActions.class.php +++ b/controller/action/i18nActions.class.php @@ -29,8 +29,11 @@ class i18nActions extends Actions throw new Exception('Please set Config::TRANSIFEX_API_KEY in your configuration.'); } - Response::setHeader(Response::HEADER_CROSS_ORIGIN, "*"); + $json = Transifex::getTranslationResourceFile($project, $resource, $language); - return View::renderJson(Transifex::getTranslationResourceFile($project, $resource, $language)); + Response::setHeader(Response::HEADER_CROSS_ORIGIN, "*"); + Response:setHeader(Response::HEADER_ETAG, md5(static::getContent($json))); + + return View::renderJson($json); } } diff --git a/view/Response.class.php b/view/Response.class.php index eb87b38d..6b73ec56 100644 --- a/view/Response.class.php +++ b/view/Response.class.php @@ -192,11 +192,6 @@ class Response ])); } - public static function setContentEtag() - { - static::setHeader(static::HEADER_ETAG, md5(static::getContent())); - } - public static function enableHttpCache(int $seconds = 300) { static::addCacheControlHeader('max-age', $seconds);