forked from neos/neos-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUGFIX: improve initial loading time by caching xliff file in browser
- Loading branch information
1 parent
90cf5bf
commit ed45489
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
Classes/Neos/Neos/Ui/Aspects/XliffConfigurationCacheHeaderAspect.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Neos\Neos\Ui\Aspects; | ||
|
||
/* * | ||
* This script belongs to the Neos Flow package "Neos.Neos.Ui". * | ||
* * | ||
* */ | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Flow\Aop\JoinPointInterface; | ||
use Neos\Flow\Session\SessionInterface; | ||
use Neos\Neos\Controller\Backend\SchemaController; | ||
|
||
/** | ||
* adds a Cache-Control: max-age=3600 header to the /xliff.json endpoint; speeds up loading the new UI. | ||
* | ||
* NOTE: we currently do this in an aspect, to also increase performance on older Neos versions (some people still | ||
* need time to upgrade to the latest Neos version...) | ||
* | ||
* @Flow\Scope("singleton") | ||
* @Flow\Aspect | ||
*/ | ||
class XliffConfigurationCacheHeaderAspect | ||
{ | ||
|
||
/** | ||
* @Flow\Inject | ||
* @var SessionInterface | ||
*/ | ||
protected $session; | ||
|
||
/** | ||
* @Flow\Before("method(Neos\Neos\Controller\Backend\BackendController->xliffAsJsonAction())") | ||
* @param JoinPointInterface $joinPoint | ||
* @return mixed | ||
*/ | ||
public function setControllerContextFromContentElementWrappingImplementation(JoinPointInterface $joinPoint) | ||
{ | ||
if ($this->session->isStarted() && $this->session->getData('__neosEnabled__')) { | ||
/** @var SchemaController $proxy */ | ||
$proxy = $joinPoint->getProxy(); | ||
|
||
// Cache for one week; as cache busting is enabled. | ||
$proxy->getControllerContext()->getResponse()->setHeader('Cache-Control', 'max-age=' . (3600 * 24 * 7)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters