所以在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