Symfony HTTP Cache doesn't work in 3.4

2019-07-24 08:28发布

I've tested code form Symfony Docs in Symfony 3.2 and it was everything good, but cache doesn't work in 3.4.8.

Of courese I want to use Symfony Reverse Proxy.

My app_dev.php

$kernel = new AppKernel('dev', true);
if (PHP_VERSION_ID < 70000) {
    $kernel->loadClassCache();
}
$kernel = new AppCache($kernel);

My action look's like this:

public function indexAction(Request $request)
{
    // [...]
    $response = $this->render('base.html.twig');

    $response->setSharedMaxAge(3600);

        return $response;
}

Am I missing something, that isn't nessesery in Symfony 3.2?

2条回答
Evening l夕情丶
2楼-- · 2019-07-24 08:40

I found it's imposible, by some Symfony 3.4 bug. I used Symfony Cache Component instead https://symfony.com/doc/current/components/cache.html.

查看更多
叛逆
3楼-- · 2019-07-24 08:43

Symfony decided to deprecate the entire ClassLoader component for Symfony 3.3+.

In this case line below is no longer available

$kernel->loadClassCache(); // deprecated

In this case you should use class loader provided by Composer. If you are not using PHP 7.0 yet, you should stay with Symfony 3.2.


Useful links

New in Symfony 3.3: Deprecated the ClassLoader component

Autoloader Optimization

查看更多
登录 后发表回答