Skip to content
Permalink
Browse files
disable caching headers in AbstractTheme if user is logged in
  • Loading branch information
Guite committed Oct 4, 2021
1 parent d5909c9 commit f085bbd0641693ee56f6d408b4493eb2e46d25cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
@@ -10,6 +10,7 @@
- [CoreBundle] Add `flex-wrap` class to pagination for responsive behaviour ([bs#23504](https://github.com/twbs/bootstrap/issues/23504)).
- [Blocks] Strip script tags from XSLT block stylesheets.
- [Categories] Sanitize context menu in admin category list.
- [Extensions] Disable caching headers in `AbstractTheme` if user is logged in.
- [Theme] Fix resolving assets location on Windows if Zikula is installed in a sub directory (#4480).
- [Permissions] Correctly handle non-existing username during permission testing.
- [Users] Dispatch `UserPostLoginFailureEvent` after login failure as expected.
@@ -18,6 +18,7 @@
use Symfony\Component\Yaml\Yaml;
use Twig\Environment;
use Zikula\ExtensionsModule\Api\VariableApi;
use Zikula\UsersModule\Api\CurrentUserApi;

abstract class AbstractTheme extends AbstractExtension
{
@@ -75,8 +76,16 @@ public function generateThemedResponse(
]);

$content = $twig->render('@' . $this->name . '/' . $template, ['maincontent' => $content]);
$response = new Response($content);

return new Response($content);
$isLoggedIn = $this->getContainer()->get(CurrentUserApi::class)->isLoggedIn();
if ($isLoggedIn) {
$response->headers->set('Cache-Control','nocache, no-store, max-age=0, must-revalidate');
$response->headers->set('Pragma','no-cache');
$response->headers->set('Expires','Sun, 02 Jan 1990 00:00:00 GMT');
}

return $response;
}

/**

0 comments on commit f085bbd

Please sign in to comment.