how to Implement if-modified-since correctly for ESI

L Cruzero lcruzero at gmail.com
Fri Mar 6 15:18:31 CET 2015


Hi, I've enabled varnish ESI processing on a config that handles public
domains passing through akamai, I've noticed that origin(varnish) is
returning a 304 to akamai which then revalidates the object and passes
stale content to the client, though ESI content has been modified, properly
parsed and visible on the origin domains.

running on varnish-3.0.6 revision 1899836

based on some tests, this not so elegant piece of vcl seems to solve the
issue, setting defaul TTL to 2mins @ akamai and updating content served by
ESI's, i've not seen any ESI content older than 2mins being served.

 if (beresp.status == 200 && beresp.http.X-ADI-NSAPP == "ssf" &&
beresp.http.Content-type ~ "html") {
               set beresp.http.Last-Modified = beresp.http.date;
                unset beresp.http.X-ADI-NSAPP;


if i removed that piece of code from my config, my ESIs go stale.

this is what my headers look like with and without the above piece of vcl


*without  *beresp.http.date *:*

HTTP/1.1 200 OK

Server: Apache

*Last-Modified: Thu, 26 Feb 2015 14:21:06 GMT*

ntCoent-Length: 7536

Cache-Control: max-age=1

Expires: Fri, 06 Mar 2015 13:41:28 GMT

Content-Type: text/html; charset=UTF-8

X-ADI-NSAPP: ssf

X-ADI-Backend: default

Date: Fri, 06 Mar 2015 13:41:27 GMT

X-Varnish: 1539216520

Age: 0

Via: 1.1 varnish

Connection: keep-alive


*with *beresp.http.date  *:*

HTTP/1.1 200 OK

Server: Apache

ntCoent-Length: 7536

Cache-Control: max-age=1

Expires: Fri, 06 Mar 2015 13:40:03 GMT

Content-Type: text/html; charset=UTF-8

X-ADI-Backend: default

*Last-Modified: Fri, 06 Mar 2015 13:40:02 GMT*

Date: Fri, 06 Mar 2015 13:40:02 GMT

X-Varnish: 1125382905

Age: 0

Via: 1.1 varnish

Connection: keep-alive

a helpful friend passed along this possible solution.

https://www.varnish-cache.org/lists/pipermail/varnish-commit/2009-June/004322.html
https://www.varnish-cache.org/trac/changeset/c64a6482f235a4f27e830d609c9a102c716d0bc6

this seems like a much more nicer way of handling ESI LM headers. any
suggestions for properly handling LM for ESIs or a way to test and
implement the above patch committed in 2009, would be most welcomed.



kind regards
-LC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20150306/27f4d8b4/attachment.html>


More information about the varnish-misc mailing list