cache i18n strings

This commit is contained in:
Jeremy Kauffman 2019-09-12 17:48:09 -04:00
parent 1bc15aad39
commit 9a070c7b3f
2 changed files with 5 additions and 7 deletions

View file

@ -29,8 +29,11 @@ class i18nActions extends Actions
throw new Exception('Please set Config::TRANSIFEX_API_KEY in your configuration.'); 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);
} }
} }

View file

@ -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) public static function enableHttpCache(int $seconds = 300)
{ {
static::addCacheControlHeader('max-age', $seconds); static::addCacheControlHeader('max-age', $seconds);