Skip to content

Commit 376417d

Browse files
committed
update for ttl support in the library
1 parent 1f2c492 commit 376417d

File tree

1 file changed

+10
-44
lines changed

1 file changed

+10
-44
lines changed

Resources/doc/reference/configuration/headers.rst

Lines changed: 10 additions & 44 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,32 +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-
C{
340-
#include <stdlib.h>
341-
}C
342-
343-
sub vcl_fetch {
344-
if (beresp.http.X-Reverse-Proxy-TTL) {
345-
C{
346-
char *ttl;
347-
ttl = VRT_GetHdr(sp, HDR_BERESP, "\024X-Reverse-Proxy-TTL:");
348-
VRT_l_beresp_ttl(sp, atoi(ttl));
349-
}C
350-
unset beresp.http.X-Reverse-Proxy-TTL;
351-
}
352-
}
353-
354-
The import for ``stdlib.h`` has to be outside of any ``vcl_X`` sub routines.
355-
Omitting the ``stdlib`` inclusion will result in a compile error complaining
356-
that ``atoi`` is not defined, and including the header file inside a VCL sub
357-
routine leads to a C compile failure mentioning
358-
``invalid storage class for function __bswap_32``.
359-
360-
Note that there is a ``beresp.ttl`` field in VCL but unfortunately it can only
361-
be set to absolute values and not dynamically. Thus we have to revert to a C
362-
code fragment.

0 commit comments

Comments
 (0)