Symfony2反向代理返回“失效”。 [英] Symfony2 reverse proxy returns "stale invalid"

查看:69
本文介绍了Symfony2反向代理返回“失效”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Symfony2反向代理缓存已通过以下设置启用(在开发环境中进行测试):

Symfony2 reverse proxy cache is enabled with the following settings(testing in the dev environment):

class AppCache extends HttpCache
{
    protected function getOptions()
    {
        return array(
            'debug'                  => true,
            'default_ttl'            => 20,
            'private_headers'        => array(),
            'allow_reload'           => false,
            'allow_revalidate'       => false,
            'stale_while_revalidate' => 21,
            'stale_if_error'         => 60,
        );
    }
}

服务器的响应如下。

从第一个请求开始(如预期):

From the first request(as expected):

X-Symfony-Cache:GET /api/posts?pageNumber=1: miss, store

来自第二个请求以及所有后续请求20秒内收到请求(如预期的那样,内容将从缓存中提供):

From the second request and all subsequent requests within 20 seconds(as expected, content being served from cache):

X-Symfony-Cache:GET /api/posts?pageNumber=1: fresh

从20秒后的请求(有问题):

From the requests after 20 seconds(problematic):

X-Symfony-Cache:GET /api/posts?pageNumber=1: stale, invalid

对于陈旧,无效响应,我不是从反向代理缓存中获取响应,而是从经历MVC周期的服务器中获取响应。

With the stale, invalid response, I get response not from the reverse proxy cache, but from the server that going through MVC cycle.

感觉有些事情在这里失败了:

Feels like a couple things failed here:


  • 过时的内容不是

  • 未重新验证缓存; i>
  • Stale content is not being served from cache;
  • Cache is not being revalidated;

任何在哪里寻找原因的想法?

Any ideas where to look for a cause?

推荐答案

在我眼中这很正常。

您提到过,从缓存中提供过时的内容是有问题的。但是,这是正常行为。 陈旧表示内容已超过其ttl(生存时间),因此不应再从缓存中投放。因此,服务器再次受到攻击,以获取新鲜内容并重新填充缓存。

You mention that it is problematic that stale content is being served from the cache. However, this is normal behaviour. 'Stale' means that the content surpassed its ttl (time to live) and should not be served from the cache anymore. Therefore the server is hit again, to get fresh content and repopulate the cache.

这篇关于Symfony2反向代理返回“失效”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆