From: Christoph Berg <myon@debian.org>
To: Dave Page <dpage@pgadmin.org>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: Jonathan S. Katz <jkatz@postgresql.org>
Cc: Daniel Gustafsson <daniel@yesql.se>
Cc: pgsql-www@lists.postgresql.org, Andrey Borodin <x4mmm@yandex-team.ru>
Cc: Melanie Plageman <melanieplageman@gmail.com>
Cc: PostgreSQL Contributors <contributors@lists.postgresql.org>
Subject: Re: Introduce contributor badges
Date: Fri, 16 Oct 2026 16:18:41 +0200
Message-ID: <atIyQWx_PwMv-PsI@msg.df7cb.de> (raw)
In-Reply-To: <atHniPzZPas6faP6@msg.df7cb.de>
References: <aszgh1hJGT6bG7QU@msg.df7cb.de>
<329b5d0e-44ba-4c5f-8cc9-c9eb5424955b@postgresql.org>
<as_JRi3I0UCkFvBJ@msg.df7cb.de>
<AC76685F-1AE4-44F9-8108-03952D02493A@yesql.se>
<c8a36992-f9f7-4ef8-bd54-15ac711ce621@postgresql.org>
<CABUevEy6LfTWE9QaJuZKyUcBkggozTp_87OLmzDSBxyo2cV1iQ@mail.gmail.com>
<atHYqT5b0eFnHEZl@msg.df7cb.de>
<CA+OCxoz62dPkZwihHVz0zt1LoAYAG-bJsEmyfPDoMkV9QN5CqA@mail.gmail.com>
<atHniPzZPas6faP6@msg.df7cb.de>
Re: To Dave Page
> > ## Varnish cache invalidation
>
> > 4. **The image URL never changes when the image does.**
> > `/community/badge/<slug>/image/` has no file extension and no version in
> > it. The docs say Varnish applies a longer policy to images "because they
> > are considered never to change". Varnish itself is purged, but if the
> > Varnish configuration (VCL) also sends long browser cache headers for
> > images, browsers will keep showing the old image.
>
> I think purging Varnish is enough here. Badge image changes aren't
> critical, if a user sees the image somewhat longer, that doesn't cause
> trouble.
I did more research on this point, and that's the result (poking
around and by Deepseek):
Key finding: the cache policy is s-maxage, i.e. shared-cache only
docs/frontend.rst:39-46:
│ There is a longer default policy set for images, because they are considered never to change. Any view …
│ can override this default, by specifying the Cache-control: s-maxage=xxx http header … using the @cache()
│ decorator.
And that's exactly what the decorator emits (pgweb/util/decorators.py):
resp['Cache-Control'] = 's-maxage=%s' % (...)
s-maxage is honoured only by shared caches (Varnish); browsers ignore it and fall back to no explicit
freshness. badge_image itself sets no Cache-Control at all (only ETag), so:
- the "longer policy for images" is a Varnish TTL (how long Varnish holds it) — and that's the copy our
purge_urls already invalidates on save;
- browsers are never asked to cache the image long, so a changed image can't go stale in a browser under the
documented design (they'll revalidate via ETag, or not cache).
So the risk in comment #4 only materialises if the out-of-repo VCL re-adds a browser max-age for images —
which would contradict the app's own header. That's a hypothetical, not something the repo does.
Recommendation
No URL versioning. It requires a schema change, and the repository's own contract (s-maxage) is
that only Varnish caches. Adding ?v=<hash> "to avoid the question" pays a real cost to guard against a
configuration the app already argues against.
On the related "minor" comment:
> - `badge_image` fetches the image and computes its MD5 before it checks
> `If-None-Match`; storing the hash would avoid both.
badge_image is only reached on a Varnish miss, and on a miss we're
almost always about to serve the image anyway. Storing the hash only
helps the narrow (?) "Django itself receives a conditional request"
case.
So, I would say everything already works like it should.
(If we wanted, We could add explicit Cache-Control headers on
badge_image.)
Christoph
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-www@postgresql.org
Cc: myon@debian.org, dpage@pgadmin.org, magnus@hagander.net, jkatz@postgresql.org, daniel@yesql.se, x4mmm@yandex-team.ru, melanieplageman@gmail.com, contributors@lists.postgresql.org
Subject: Re: Introduce contributor badges
In-Reply-To: <atIyQWx_PwMv-PsI@msg.df7cb.de>
References: <aszgh1hJGT6bG7QU@msg.df7cb.de> <329b5d0e-44ba-4c5f-8cc9-c9eb5424955b@postgresql.org> <as_JRi3I0UCkFvBJ@msg.df7cb.de> <AC76685F-1AE4-44F9-8108-03952D02493A@yesql.se> <c8a36992-f9f7-4ef8-bd54-15ac711ce621@postgresql.org> <CABUevEy6LfTWE9QaJuZKyUcBkggozTp_87OLmzDSBxyo2cV1iQ@mail.gmail.com> <atHYqT5b0eFnHEZl@msg.df7cb.de> <CA+OCxoz62dPkZwihHVz0zt1LoAYAG-bJsEmyfPDoMkV9QN5CqA@mail.gmail.com> <atHniPzZPas6faP6@msg.df7cb.de> <atIyQWx_PwMv-PsI@msg.df7cb.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox