Skip to content

Commit ffd6b9f

Browse files
committed
update for ttl support in the library
1 parent aa20b2a commit ffd6b9f

File tree

2 files changed

+15
-37
lines changed

2 files changed

+15
-37
lines changed

Resources/doc/reference/configuration/headers.rst

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -298,24 +298,19 @@ keeping previously set Vary options:
298298

299299
**type**: ``integer``
300300

301-
Set a X-Reverse-Proxy-TTL header for reverse proxy time-outs not driven by ``s-maxage``.
301+
Set a X-Reverse-Proxy-TTL header for reverse proxy time-outs not driven by
302+
``s-maxage``. This keeps your ``s-maxage`` free for use with reverse proxies
303+
not under your control.
302304

303-
By default, reverse proxies use the ``s-maxage`` of your ``Cache-Control`` header
304-
to know how long it should cache a page. But by default, the ``s-maxage`` is also
305-
sent to the client. Any caches on the Internet, for example at an Internet
306-
provider or in the office of a surfer, might look at ``s-maxage`` and
307-
cache the page if it is ``public``. This can be a problem, notably when you do
308-
:doc:`explicit cache invalidation </reference/cache-manager>`. You might want your reverse
309-
proxy to keep a page in cache for a long time, but outside caches should not
310-
keep the page for a long duration.
305+
.. warning::
311306

312-
One option could be to set a high ``s-maxage`` for the proxy and simply rewrite
313-
the response to remove or reduce the ``s-maxage``. This is not a good solution
314-
however, as you start to duplicate your caching rule definitions.
307+
This is a custom header. You need to set up your caching proxy to respect
308+
this header. See the FOSHttpCache documentation
309+
:ref:`for Varnish <foshttpcache:varnish configuration>` or
310+
:ref:`for the Symfony HttpCache <foshttpcache:symfony cache configuration>`.
315311

316-
This bundle helps you to build a better solution: You can specify the option
317-
``reverse_proxy_ttl`` in the headers section to get a special header that you can
318-
then use on the reverse proxy:
312+
To use the custom TTL, specify the option ``reverse_proxy_ttl`` in the headers
313+
section:
319314

320315
.. code-block:: yaml
321316
@@ -331,22 +326,3 @@ then use on the reverse proxy:
331326
s_maxage: 60
332327
333328
This example adds the header ``X-Reverse-Proxy-TTL: 3600`` to your responses.
334-
Varnish by default knows nothing about this header. To make this solution work,
335-
you need to extend your varnish ``vcl_fetch`` configuration:
336-
337-
.. code-block:: c
338-
339-
sub vcl_fetch {
340-
if (beresp.http.X-Reverse-Proxy-TTL) {
341-
C{
342-
char *ttl;
343-
ttl = VRT_GetHdr(sp, HDR_BERESP, "\024X-Reverse-Proxy-TTL:");
344-
VRT_l_beresp_ttl(sp, atoi(ttl));
345-
}C
346-
unset beresp.http.X-Reverse-Proxy-TTL;
347-
}
348-
}
349-
350-
Note that there is a ``beresp.ttl`` field in VCL but unfortunately it can only
351-
be set to absolute values and not dynamically. Thus we have to revert to a C
352-
code fragment.

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
}
2222
],
2323
"require": {
24-
"php": ">=5.3.3",
25-
"friendsofsymfony/http-cache": "~1.4",
24+
"php": ">=5.4.8",
25+
"friendsofsymfony/http-cache": "~2.0@dev",
2626
"symfony/framework-bundle": "~2.3"
2727
},
2828
"require-dev": {
@@ -33,6 +33,8 @@
3333
"symfony/phpunit-bridge": "~2.7",
3434
"symfony/expression-language": "~2.4",
3535
"symfony/monolog-bundle": "~2.3",
36+
"php-http/guzzle6-adapter": "^0.1.0",
37+
"guzzlehttp/psr7": "^1.0",
3638
"polishsymfonycommunity/symfony-mocker-container": "~1.0",
3739
"matthiasnoback/symfony-dependency-injection-test": "0.*"
3840
},
@@ -48,7 +50,7 @@
4850
},
4951
"extra": {
5052
"branch-alias": {
51-
"dev-master": "1.3.x-dev"
53+
"dev-master": "2.0.x-dev"
5254
}
5355
}
5456
}

0 commit comments

Comments
 (0)