Is there any added cost (in terms of pricing and/or latency) of using secrets in workers (ie Commands · Cloudflare Workers docs) vs plain variables.
Only while plain environment variables can be stored in the script, I wondered whether behind the scenes secrets uses KV … which has a cost per read in dollars and latency. So if I store 5 secrets, would that incur 5 KV reads on every script execution.
It doesn’t use KV so I don’t think it has any cost, but you can only have a very limited amount of secrets.
To avoid both limitations, I store an encryption key inside a secret and use that to unlock a KV that holds the actual secrets. To create the encrypted KV; I use a local function that uses the secret to encrypt and upload it. To avoid cost, the KV can be stored in cache and only be invalidated when needed.