我遇到了 Goutte 的问题,或者实际上是 Goutte 的 Guzzle 部分。
Guzzle 确实会自动缓存每个 GET 调用,我试图禁用它,但我无法真正让它工作。
正如您在此处看到的,我将缓存参数直接解析到 Guzzle 构造函数中。
use Goutte\Client;
use Guzzle\Http\Client as GuzzleClient;
$client = new Client();
$client->setClient(new GuzzleClient('/', array(
'curl.options' => array(
CURLOPT_COOKIESESSION => true,
CURLOPT_COOKIEJAR => 'cookie.txt',
CURLOPT_FRESH_CONNECT => true,
CURLOPT_TIMEOUT => 0
),
'params.cache.override_ttl' => 0,
'params.cache.default_ttl' => 0,
'params.cache.revalidate' => 'always'
)));
但是,这不会进行任何更改。从缓存插件的文档开始(参见:http ://guzzlephp.org/guide/http/caching.html )
这段代码:
echo $client->getClient()->get('/')->getParams()->get('cache.override_ttl');
应该输出cache.override_ttl的当前值,这不会输出任何东西。
我相信这一定是关于 Goutte 包装的东西,我忽略了。有人有想法么?