Index | Thread | Search

From:
Kirill A. Korinsky <kirill@korins.ky>
Subject:
Re: httpd: add cache controls for static files
To:
Job Snijders <job@bsd.nl>
Cc:
tech@openbsd.org
Date:
Wed, 13 May 2026 17:33:09 +0200

Download raw body.

Thread
On Wed, 13 May 2026 16:26:01 +0200,
Job Snijders <job@bsd.nl> wrote:
> 
> On Sun, May 10, 2026 at 01:39:20PM +0200, Kirill A. Korinsky wrote:
> > +cache		: NO CACHE		{
> > +			srv_conf->flags &= ~SRVFLAG_CACHE;
> > +			srv_conf->flags |= SRVFLAG_NO_CACHE;
> > +		}
> > +		| CACHE			{
> > +			srv_conf->flags &= ~SRVFLAG_NO_CACHE;
> > +			srv_conf->flags |= SRVFLAG_CACHE;
> > +		}
> > +		;
> > +
> 
> Perhaps "[no] cache-control no-cache" ? This way we can add
> more directives in the future, and also allow location specific
> configuration. E.g., 
> 
> server "example.com" {
> 	listen on * port 80
> 
> 	gzip-static
> 	no cache-control no-cache
> 
> 	location "/hotstuff/*" {
> 		cache-control no-cache
> 	}
> }
> 
> alternative approach would be to provide some generic mechanism to set
> HTTP headers (send-header?), then operators can just do whatever they
> need to do without patching httpd?
> 
> server "example.com" {
> 	listen on * port 80
> 
> 	gzip-static
> 
> 	location "/hotstuff/*" {
> 		send-header "Cache-Control: no-cache"
> 	}
> }
> 

You missed that it is not just Cache-Control: no-cache, but it actually
needs to Vary: Accept-Encoding that makes [no] cache-control no-cache not
that clear I think.

Next, send-header or add-header is possible approach, but my diff adds it
out of the box because mtime / Last-Modified for static files makes it safe.

-- 
wbr, Kirill