简体   繁体   English

Symfony2 AppCache性能提升

[英]Symfony2 AppCache performance boost

We're trying to figure out what effect enabling AppCache in the frontend controller has on caching without calling any cache directives on the response object. 我们试图弄清楚在前端控制器中启用AppCache对缓存的影响,而不调用响应对象上的任何缓存指令。

I had presumed that simply adding the following line and setting default_ttl to 1: 我原以为只需添加以下行并将default_ttl设置为1:

$kernel = new AppCache($kernel);

would not change the behaviour of the application without calling a cache directive on the response. 如果不在响应上调用缓存指令,则不会更改应用程序的行为。 But as soon as we add this line (and cache:clear) our server is able to handle far more requests per second, which suggests that there is some caching going on. 但是一旦我们添加这一行(和cache:clear),我们的服务器就能够每秒处理更多的请求,这表明存在一些缓存。

Turning on debug and setting default_ttl to an hour all we see in the http headers is 打开调试并将default_ttl设置为一小时我们在http标头中看到的是

X-Symfony-Cache: GET /: miss

Does this mean that there is no reverse proxy caching going on? 这是否意味着没有反向代理缓存? If so what explains the performance increase? 如果是这样,是什么解释了性能提升

Any clarification on what happens in this situation would be awesome. 对这种情况发生的事情的任何澄清都会很棒。

This line 这条线

$kernel = new AppCache($kernel);

enables the Symfony2 Reverse Proxy. 启用S​​ymfony2反向代理。 For further explanation follow this link: http://symfony.com/doc/current/book/http_cache.html#symfony2-reverse-proxy . 有关进一步说明,请访问以下链接: http//symfony.com/doc/current/book/http_cache.html#symfony2-reverse-proxy The performance increase should be clear now. 性能提升现在应该很清楚。

The header means that the "Symfony-Cache" got a "GET" request and found no cached data ("miss"). 标题意味着“Symfony-Cache”得到“GET”请求并且没有找到缓存数据(“miss”)。 If you call the same page multiple times in a row the header should change to something like: 如果您连续多次调用同一页面,则标题应更改为:

X-Symfony-Cache: GET /: HIT 42

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM