Temporarily redirect to HTTP while certificate is being generated

1. The problem I’m having:

I am deploying Caddy in a setup where I have a need to generate a lot of certificates (on a random day, I might need 40k new certificates). The certificates take a bit to generate, and while they are generating, I’d like to redirect traffic to http.

My question is, is this kind of setup possible? My first thought was to look at file existence in the http block and redirect to https. But then how do I redirect from https to http?

Anyway, I’m not using the file storage adapter, but Redis. Ideally, in the https block Caddy should look at the storage adapter, check if the certificate exists, if not, redirect to http.

On the http block, check if the certificate exists, if it does, redirect to https.

If it helps somehow using the file adapter, I could see if I could swap, but that would give me other issues with synchronizing the certificates.