小编Pio*_*ski的帖子

Symfony HTTP Cache-Control标头覆盖

我前段时间回答过这个问题.

我在Symfony 3.4中的代码.

 $response->setCache([
     'max_age' => 3600,
     'public' => true,
     's_maxage' => 3600,
 ]);


 // (optional) set a custom Cache-Control directive
 $response->headers->addCacheControlDirective('must-revalidate', true);

 return $response;
Run Code Online (Sandbox Code Playgroud)

在某些原因,我仍然得到Cache-Control像这样的其他标题:

Cache-Control: max-age=0, must-revalidate, private, s-maxage=3600
X-Symfony-Cache: GET /: miss
Run Code Online (Sandbox Code Playgroud)

我注意到在Symfony 3.2代码中运行良好,但在3.4中我没有进入publicCache-Control(并且max-age=0看起来也很糟糕).

第二件事是$response在控制器中倾倒- 一切看起来都很好:

#headers: array:2 [?
  "cache-control" => array:1 [?
    0 => "max-age=3600, must-revalidate, public, s-maxage=3600"
  ]
  "date" => array:1 [?
    0 => "Sat, 12 May 2018 18:42:04 GMT"
  ]
]
Run Code Online (Sandbox Code Playgroud)

它是某种Symfony bug吗?我应该报告吗?

caching http cache-control symfony

3
推荐指数
1
解决办法
900
查看次数

标签 统计

cache-control ×1

caching ×1

http ×1

symfony ×1