Skip to content

Commit

Permalink
BUGFIX: improve initial loading time by caching xliff file in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
skurfuerst committed Apr 4, 2018
1 parent 90cf5bf commit ed45489
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
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));
}
}
}
6 changes: 6 additions & 0 deletions Resources/Private/Fusion/Backend/Root.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ backend = Neos.Fusion:Template {
absolute = true
arguments = Neos.Fusion:RawArray {
locale = ${interfaceLanguage}

# TODO: dirty hack to not have to re-implement neos:backend.configurationCacheVersion VH
version = Neos.Fusion:Template {
templatePath = 'resource://Neos.Neos.Ui/Private/Templates/Backend/ConfigurationVersion.html'
@process.trim = ${String.trim(value)}
}
}
}
}
Expand Down

0 comments on commit ed45489

Please sign in to comment.