Commit 3419a387 authored by Fabien Potencier's avatar Fabien Potencier

merged branch blongden/http-cache-docs (PR #501)

This PR was merged into the master branch.

Commits
-------

be648301 Takes advantage of fluent interface on Response object
fac3649a Updated to use setTtl

Discussion
----------

Updated http cache docs to use setTtl

Previous version set Cache-Control s-maxage headers explicitly which is
not enough to trigger ESI caching in the reverse proxy. Using setTtl is
enough to make this work correctly.

---------------------------------------------------------------------------

by igorw at 2012-09-30T13:23:43Z

👍
parents 810fcb19 be648301
...@@ -59,7 +59,7 @@ Silex applications by using the ``http_cache`` service:: ...@@ -59,7 +59,7 @@ Silex applications by using the ``http_cache`` service::
The provider also provides ESI support:: The provider also provides ESI support::
$app->get('/', function() { $app->get('/', function() {
return new Response(<<<EOF $response = new Response(<<<EOF
<html> <html>
<body> <body>
Hello Hello
...@@ -69,15 +69,15 @@ The provider also provides ESI support:: ...@@ -69,15 +69,15 @@ The provider also provides ESI support::
EOF EOF
, 200, array( , 200, array(
'Cache-Control' => 's-maxage=20',
'Surrogate-Control' => 'content="ESI/1.0"', 'Surrogate-Control' => 'content="ESI/1.0"',
)); ));
return $response->setTtl(20);
}); });
$app->get('/included', function() { $app->get('/included', function() {
return new Response('Foo', 200, array( $response = new Response('Foo');
'Cache-Control' => 's-maxage=5', return $response->setTtl(5);
));
}); });
$app['http_cache']->run(); $app['http_cache']->run();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment