File tree Expand file tree Collapse file tree 4 files changed +14
-31
lines changed Expand file tree Collapse file tree 4 files changed +14
-31
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
1212* Added support for the more efficient xkey cache tag system. BAN remains the
1313 default cache tagging system, but if you can install the varnish modules in
1414 your system, it is recommended to update to xkey.
15+ * No inline C is needed for the custom TTL header with Varnish 4 or better. use
16+ ` std.duration() ` instead.
1517
1618### Symfony user context
1719* You can now also specify which headers are used for
Original file line number Diff line number Diff line change @@ -384,10 +384,7 @@ Custom TTL
384384.. include :: includes/custom-ttl.rst
385385
386386Subroutines are provided in ``resources/config/varnish-[version]/fos_custom_ttl.vcl ``.
387- The configuration needs to use inline C, which is disabled by default since
388- Varnish 4.0. To use the custom TTL feature, you need to start your Varnish with
389- inline C enabled: ``-p vcc_allow_inline_c=on ``. Then add the following to
390- ``your_varnish.vcl ``:
387+ Add the following to ``your_varnish.vcl ``:
391388
392389.. configuration-block ::
393390
@@ -409,6 +406,14 @@ inline C enabled: ``-p vcc_allow_inline_c=on``. Then add the following to
409406
410407 The custom TTL header is removed before sending the response to the client.
411408
409+ .. note ::
410+
411+ If you are using Varnish 3, this feature is using inline C. Inline C is
412+ enabled for Varnish 3 by default. Check for the ``vcc_allow_inline_c ``
413+ setting.
414+ If you are using Varnish 4 or newer, you are using the
415+ ``varnish/fos_custom_ttl.vcl `` which uses a vmod function instead of inline C.
416+
412417.. _varnish_debugging :
413418
414419Debugging
Original file line number Diff line number Diff line change 66 * For the full copyright and license information, please view the LICENSE
77 * file that was distributed with this source code.
88 */
9- C{
10- #include <stdlib.h>
11- }C
9+
10+ import std;
1211
1312/**
1413 * Read a custom TTL header for the time to live information, to be used
1514 * instead of s-maxage.
1615 */
1716sub fos_custom_ttl_backend_response {
1817 if (beresp.http.X-Reverse-Proxy-TTL ) {
19- /*
20- * Note that there is a ``beresp.ttl`` field in VCL but unfortunately
21- * it can only be set to absolute values and not dynamically. Thus we
22- * have to resort to an inline C code fragment.
23- *
24- * As of Varnish 4.0, inline C is disabled by default. To use this
25- * feature, you need to add `-p vcc_allow_inline_c=on` to your Varnish
26- * startup command.
27- */
28- C{
29- const char *ttl;
30- const struct gethdr_s hdr = { HDR_BERESP, "\0 24X-Reverse-Proxy-TTL:" };
31- ttl = VRT_GetHdr(ctx, &hdr);
32- VRT_l_beresp_ttl(ctx, atoi(ttl));
33- }C
34-
18+ set beresp.ttl = std.duration(beresp.http.X-Reverse-Proxy-TTL + "s" , 0s );
3519 unset beresp.http.X-Reverse-Proxy-TTL ;
3620 }
3721}
Original file line number Diff line number Diff line change 1919 */
2020class CustomTtlTest extends VarnishTestCase
2121{
22- public function setUp ()
23- {
24- if ($ this ->getVarnishVersion () >= 4 ) {
25- $ this ->getProxy ()->setAllowInlineC (true );
26- }
27- parent ::setUp ();
28- }
29-
3022 protected function getConfigFile ()
3123 {
3224 switch ((int ) $ this ->getVarnishVersion ()) {
You can’t perform that action at this time.
0 commit comments