Skip to content

Commit d32188f

Browse files
committed
Provide test functionality in traits
Fix #202. separate http client from trait Make property and methods private Add traits to docs
1 parent bb3ff1d commit d32188f

14 files changed

+925
-631
lines changed

doc/includes/symfony-process.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Requires Symfony’s Process component, so make sure to include that in your
2+
project:
3+
4+
.. code-block:: bash
5+
6+
$ composer require symfony/process

doc/proxy-clients.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Then pass that adapter to the caching proxy client::
6666
$proxyClient = new Varnish($servers, '/baseUrl', $adapter);
6767
// Varnish as example, but also possible for NGINX and Symfony
6868

69+
.. _varnish client:
70+
6971
Varnish Client
7072
~~~~~~~~~~~~~~
7173

doc/symfony-cache-configuration.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,34 @@ the ``session_name_prefix`` option) in the requests to the backend. If you need
179179
a different behavior, overwrite ``UserContextSubscriber::cleanupHashLookupRequest``
180180
with your own logic.
181181

182+
.. _symfony-cache x-debugging:
183+
184+
Debugging
185+
~~~~~~~~~
186+
187+
For the ``assertHit`` and ``assertMiss`` assertions to work, you need to add
188+
debug information in your AppCache. Create the cache kernel with the option
189+
``'debug' => true`` and add the following to your ``AppCache``::
190+
191+
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
192+
{
193+
$response = parent::handle($request, $type, $catch);
194+
195+
if ($response->headers->has('X-Symfony-Cache')) {
196+
if (false !== strpos($response->headers->get('X-Symfony-Cache'), 'miss')) {
197+
$state = 'MISS';
198+
} elseif (false !== strpos($response->headers->get('X-Symfony-Cache'), 'fresh')) {
199+
$state = 'HIT';
200+
} else {
201+
$state = 'UNDETERMINED';
202+
}
203+
$response->headers->set('X-Cache', $state);
204+
}
205+
206+
return $response;
207+
}
208+
209+
The ``UNDETERMINED`` state should never happen. If it does, it means that your
210+
HttpCache is not correctly set into debug mode.
211+
182212
.. _HttpCache: http://symfony.com/doc/current/book/http_cache.html#symfony-reverse-proxy

0 commit comments

Comments
 (0)