나를 위해이 일을하지만 내 환경 클래스를 수정했습니다. 당신은 당신의 자신의 캐시 경로 및 환경을 사용할 수 있습니다
private function clearCache($slug)
{
global $kernel;
if (get_class($kernel) == 'AppCache') {
$key = 'md' . hash('sha256', ($_SERVER['SERVER_PORT'] == 80 ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . '/' . $slug);
$cacheMdFileName = \Environment::instance()->getCachePath() . '/' . $kernel->getKernel()->getEnvironment() . DIRECTORY_SEPARATOR . 'http_cache' . DIRECTORY_SEPARATOR . substr($key, 0, 2) . DIRECTORY_SEPARATOR . substr($key, 2, 2) . DIRECTORY_SEPARATOR . substr($key, 4, 2) . DIRECTORY_SEPARATOR . substr($key, 6);
$file = file_get_contents($cacheMdFileName);
$key = unserialize($file)[0][1]['x-content-digest'][0];
$cacheEnFileName = \Environment::instance()->getCachePath() . '/' . $kernel->getKernel()->getEnvironment() . DIRECTORY_SEPARATOR . 'http_cache' . DIRECTORY_SEPARATOR . substr($key, 0, 2) . DIRECTORY_SEPARATOR . substr($key, 2, 2) . DIRECTORY_SEPARATOR . substr($key, 4, 2) . DIRECTORY_SEPARATOR . substr($key, 6);
unlink($cacheMdFileName);
unlink($cacheEnFileName);
}
}
읽기는 온라인 문서에서 –
말했다 http://symfony.com/doc/2.0/book/http_cache.html : "가장 표준 방법이다 특정 URL에 대해 캐시를 지우려면 PURGE HTTP 메소드를 사용하여 캐시를 요청하십시오. " 하지만 symfony 컨트롤러 내부에서 PURGE HTTP 메서드를 만들려면 어떻게해야합니까? – Developer