所以在Symfony2中,我需要做到以下幾點:的Symfony 2的Symfony 分量 HttpFoundation HeaderBag標頭
$response->headers->addCacheControlDirective();
$response->headers->addCacheControlDirective();
$response->headers->addCacheControlDirective();
$response->headers->addCacheControlDirective();
上述方法都在裏面:
namespace Symfony\Component\HttpFoundation;
class HeaderBag
我有它通過更新我的app_dev工作.php和app.php並加入以下內容:
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
這是修改sh頭文件的正確方法我應該做點什麼嗎?
有點新來Symfony,我想做的一切都是正確的方式。
羅馬的很多方法,如果你想爲所有的請求/響應的頭,你的解決方案可能是好的,如果它的工作 – 2014-09-11 13:09:50
是的,它只是不知道我是否需要擴展任何東西或做一些奇特的時髦的方式。 – 2014-09-11 13:14:14
你看過http緩存章節嗎? http://symfony.com/doc/current/book/http_cache.html。我想你可能會在那裏找到你的時髦方法。 – Cerad 2014-09-11 13:32:22