Mailing List Archive

Purging cached std.fileread() contents
I'm trying to test a simple Varnish setup with no backend to serve a single index.html file. This is for use on a maintenance page web server when the main web site is down, more specifically, behind an AWS ALB with two target groups, one with the main web servers and the other with two lightweight maintenance page servers. I figured that it'd be nice to just leave out a Nginx configuration since a single static file is all that's needed (images referenced in the HTML are from other sources).

I'm using std.fileread("/var/www/html/index.html") to set the resp.body. The documentation for std.fileread() says it is cached indefinitely, so how do I get Varnish to re-read the file when it gets updated without having to restart Varnish? The reason for this is that the maintenance page lists the ETA when the web site should be back up, so if I need to extend the maintenance, I have a manual script that creates and deploys a new version of the file to the maintenance page servers.

Justin
Re: Purging cached std.fileread() contents [ In reply to ]
On 6/15/23 18:57, Justin Lloyd wrote:
>
> The documentation for std.fileread() says it is cached indefinitely, so
> how do I get Varnish to re-read the file when it gets updated without
> having to restart Varnish?

"Cached indefinitely" means just what it says. The VMOD saves the file
contents in memory on the first invocation of std.fileread(), and never
reads the file again.

We have a VMOD that reads file contents and then monitors the file for
changes. The new contents are used after the change:

https://code.uplex.de/uplex-varnish/libvmod-file


Best,
Geoff
--
** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

http://uplex.de
Re: Purging cached std.fileread() contents [ In reply to ]
Piling on here, there's also one in rust!
https://github.com/gquintard/vmod_fileserver

On Thu, Jun 15, 2023, 19:44 Geoff Simmons <geoff@uplex.de> wrote:

> On 6/15/23 18:57, Justin Lloyd wrote:
> >
> > The documentation for std.fileread() says it is cached indefinitely, so
> > how do I get Varnish to re-read the file when it gets updated without
> > having to restart Varnish?
>
> "Cached indefinitely" means just what it says. The VMOD saves the file
> contents in memory on the first invocation of std.fileread(), and never
> reads the file again.
>
> We have a VMOD that reads file contents and then monitors the file for
> changes. The new contents are used after the change:
>
> https://code.uplex.de/uplex-varnish/libvmod-file
>
>
> Best,
> Geoff
> --
> ** * * UPLEX - Nils Goroll Systemoptimierung
>
> Scheffelstraße 32
> 22301 Hamburg
>
> Tel +49 40 2880 5731
> Mob +49 176 636 90917
> Fax +49 40 42949753
>
> http://uplex.de
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
RE: Purging cached std.fileread() contents [ In reply to ]
Thank you both for the responses. However, I have a strong aversion to using miscellaneous 3rd party unsupported software, especially for something so relatively trivial, and something that has to be compiled and monitored for updates, that I'd think would be a native feature. It seems like it'd just be simpler to stick with a basic Nginx backend. (That said, I've actually been developing an alternate design from ec2 instances to a Lambda, but that has its own set of complexities, even for something as simple as a single, static maintenance page.)

Justin

From: varnish-misc <varnish-misc-bounces+justinl=arena.net@varnish-cache.org> On Behalf Of Guillaume Quintard
Sent: Thursday, June 15, 2023 10:52 AM
To: Geoffrey Simmons <geoff@uplex.de>
Cc: varnish-misc@varnish-cache.org
Subject: Re: Purging cached std.fileread() contents

Piling on here, there's also one in rust!
https://github.com/gquintard/vmod_fileserver

On Thu, Jun 15, 2023, 19:44 Geoff Simmons <geoff@uplex.de<mailto:geoff@uplex.de>> wrote:
On 6/15/23 18:57, Justin Lloyd wrote:
>
> The documentation for std.fileread() says it is cached indefinitely, so
> how do I get Varnish to re-read the file when it gets updated without
> having to restart Varnish?

"Cached indefinitely" means just what it says. The VMOD saves the file
contents in memory on the first invocation of std.fileread(), and never
reads the file again.

We have a VMOD that reads file contents and then monitors the file for
changes. The new contents are used after the change:

https://code.uplex.de/uplex-varnish/libvmod-file


Best,
Geoff
--
** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstra?e 32
22301 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

http://uplex.de<http://uplex.de/>

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc