For a website development, I try to use Symfony 4 HTTP cache described in documentation.
I created an CacheKernel called in index.php like this :
namespace App;
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
class CacheKernel extends HttpCache
{
}
// index.php
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new CacheKernel($kernel);
$request = Request::createFromGlobals();
In homepage action:
$response->setPublic();
$response->setMaxAge(3600);
$response->headers->addCacheControlDirective('must-revalidate', true);
return $response;
In profiler, headers are sets :
cache-control "max-age=3600, must-revalidate, public"
But in browser, headers are not same, and I think cache is not stored :
Cache-Control: max-age=0, must-revalidate, private
Have you got some ides to understand why headers are not same and why cache is not working please ?
And how can I make be sure cache is working, is there some logs ?
Thanks a lot for helping
source https://stackoverflow.com/questions/68963729/symfony-4-http-cache-headers-not-same-in-profiler-and-browser
Comments
Post a Comment