Merge pull request #4391 from Icinga/improve-cache-handling

Improve cache handling
This commit is contained in:
Johannes Meyer 2021-06-18 13:57:30 +02:00 committed by GitHub
commit 35659c8d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 14 deletions

View File

@ -176,11 +176,22 @@ class ConfigController extends Controller
$form = new ActionForm();
$form->setOnSuccess(function (ActionForm $form) {
$module = $form->getValue('identifier');
Icinga::app()->getModuleManager()->enableModule($module);
Notification::success(sprintf($this->translate('Module "%s" enabled'), $module));
$moduleName = $form->getValue('identifier');
$module = Icinga::app()->getModuleManager()
->enableModule($moduleName)
->getModule($moduleName);
Notification::success(sprintf($this->translate('Module "%s" enabled'), $moduleName));
$form->onSuccess();
$this->redirectHttp('config/modules');
if ($module->hasJs()) {
$this->redirectHttp('config/modules');
} else {
if ($module->hasCss()) {
$this->reloadCss();
}
$this->rerenderLayout()->redirectNow('config/modules');
}
});
try {
@ -202,11 +213,22 @@ class ConfigController extends Controller
$form = new ActionForm();
$form->setOnSuccess(function (ActionForm $form) {
$module = $form->getValue('identifier');
Icinga::app()->getModuleManager()->disableModule($module);
Notification::success(sprintf($this->translate('Module "%s" disabled'), $module));
$mm = Icinga::app()->getModuleManager();
$moduleName = $form->getValue('identifier');
$module = $mm->getModule($moduleName);
$mm->disableModule($moduleName);
Notification::success(sprintf($this->translate('Module "%s" disabled'), $moduleName));
$form->onSuccess();
$this->redirectHttp('config/modules');
if ($module->hasJs()) {
$this->redirectHttp('config/modules');
} else {
if ($module->hasCss()) {
$this->reloadCss();
}
$this->rerenderLayout()->redirectNow('config/modules');
}
});
try {

View File

@ -129,7 +129,7 @@ class JavaScript
$request = Icinga::app()->getRequest();
$noCache = $request->getHeader('Cache-Control') === 'no-cache' || $request->getHeader('Pragma') === 'no-cache';
header('Cache-Control: public');
header('Cache-Control: public,no-cache,must-revalidate');
if (! $noCache && FileCache::etagMatchesFiles($files)) {
header("HTTP/1.1 304 Not Modified");

View File

@ -192,7 +192,7 @@ class StyleSheet
$request = $styleSheet->app->getRequest();
$response = $styleSheet->app->getResponse();
$response->setHeader('Cache-Control', 'public', true);
$response->setHeader('Cache-Control', 'private,no-cache,must-revalidate', true);
$noCache = $request->getHeader('Cache-Control') === 'no-cache' || $request->getHeader('Pragma') === 'no-cache';

View File

@ -111,10 +111,7 @@
var $oldLink = $(this);
if ($oldLink.hasAttr('type') && $oldLink.attr('type').indexOf('css') > -1) {
var base = location.protocol + '//' + location.host;
var url = icinga.utils.addUrlParams(
$(this).attr('href'),
{ id: new Date().getTime() }
);
var url = $(this).attr('href');
var $newLink = $oldLink.clone().attr(
'href',