I’m using Caddy 0.10.10 on Windows 10 Pro with a small
static website. I want to use a Service Worker so the
site can run offline.
There is a problem with the redirects from <path>/index.html to <path>/ which Caddy does
automagically via 302 redirects. Using a Service Worker
data for both paths is saved, which is annoying and
wasteful. I can’t find any way to avoid the double hit.
Is there any chance of making the redirect a configurable
option in future versions of Caddy?
Thanks for the reply. The problem is more with the Service Worker (or my understanding of it) than Caddy. You have to provide a set of paths to be offline, and the default behaviour is to follow redirects and scoop up the data. So for the file foo/index.html there would be three copies for foo, foo/ and foo/index.html. I could make a Caddy-specific Service Worker which did what you’re suggesting in the service worker, but I’d need something different on other platforms. I guess I thought that a static website should be able to have a single service worker for all server platforms.
I’m interested to know whether anyone else has had SW problems and has thought of a solution…
Sorry, I’ve got no experience at all with Service Workers. From your original post I’d assumed that the issue was that Caddy gave 302s rather than 301s, so the Caddyfile snippet I gave simply configures Caddy to give 301s instead.
Could you clarify exactly what you want Caddy to do in an ideal setup?