Fix incorrect Last-Modified from backend?

Dridi Boukelmoune dridi at varni.sh
Thu Mar 19 09:57:47 UTC 2020


On Wed, Mar 18, 2020 at 2:17 PM Batanun B <batanun at hotmail.com> wrote:
>
> Hi,
>
> Long story short, one of our backend systems serves an incorrect Last-Modified response header, and I don't see a way to fix it at the source (third party system, not based on Nginx/Tomcat/IIS or anything like that).
>
> So, I would like to "fix" it in Varnish, since I don't expect the maker of that software being able to fix this within a reasonable time. Is there a built in way in Varnish to make it generate it's own Last-Modified response header? Something like:
>
> * If no stale object exists in cache, set Last-Modified to the value of the Date response header
> * If a stale object exists in cache, and it's body content is identical to the newly fetched content, keep the Last-Modified from the step above
> * If a stale object exists in cache, but it's body content is different to the newly fetched content, set Last-Modified to the value of the Date response header

I don't think you can do something like that without writing a module,
and even if you could you would still have a chicken-egg problem for
streaming deliveries when it comes to generating a header based on the
contents of the body (you would need trailers, but we don't support
them).

By the way, when it comes to revalidation based on the body, you
should use ETag instead of Last-Modified.

> Any suggestions on how to handle this situation? Any general Varnish guidelines when working with a backend that acts like this?

I think that's a tough nut to crack. There are many things you can
work around from a misbehaving backend but this case is not trivial.

Dridi


More information about the varnish-misc mailing list