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
12
12
* Added support for the more efficient xkey cache tag system. BAN remains the
13
13
default cache tagging system, but if you can install the varnish modules in
14
14
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.
15
17
16
18
### Symfony user context
17
19
* 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
384
384
.. include :: includes/custom-ttl.rst
385
385
386
386
Subroutines 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 ``:
391
388
392
389
.. configuration-block ::
393
390
@@ -409,6 +406,14 @@ inline C enabled: ``-p vcc_allow_inline_c=on``. Then add the following to
409
406
410
407
The custom TTL header is removed before sending the response to the client.
411
408
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
+
412
417
.. _varnish_debugging :
413
418
414
419
Debugging
Original file line number Diff line number Diff line change 6
6
* For the full copyright and license information, please view the LICENSE
7
7
* file that was distributed with this source code.
8
8
*/
9
- C{
10
- #include <stdlib.h>
11
- }C
9
+
10
+ import std;
12
11
13
12
/**
14
13
* Read a custom TTL header for the time to live information, to be used
15
14
* instead of s-maxage.
16
15
*/
17
16
sub fos_custom_ttl_backend_response {
18
17
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 );
35
19
unset beresp.http.X-Reverse-Proxy-TTL ;
36
20
}
37
21
}
Original file line number Diff line number Diff line change 19
19
*/
20
20
class CustomTtlTest extends VarnishTestCase
21
21
{
22
- public function setUp ()
23
- {
24
- if ($ this ->getVarnishVersion () >= 4 ) {
25
- $ this ->getProxy ()->setAllowInlineC (true );
26
- }
27
- parent ::setUp ();
28
- }
29
-
30
22
protected function getConfigFile ()
31
23
{
32
24
switch ((int ) $ this ->getVarnishVersion ()) {
You can’t perform that action at this time.
0 commit comments