If multiple users visit the page at the same time, and both get a cache-miss, then two images are being generated. The last one will overwrite any existing. This is expensive for my wallet since we generate more images than we use. (The code that generates images for normal users is still there until we have validated the generate endpoint approach)
Users will load the site faster, since the chance of getting a cache-miss will be lower
How
The new endpoint is not meant for normal users to query, instead, I was thinking we could use cron-job.com - A free service that can query your API.
cron-job.com waits up to 30 seconds before timeout, which is not always enough for us, which is why the generate endpoint just starts the image generation tasks, but does not await them before returning.
There is a new env variable that should be set to any random value of your liking, we just need to re-use it in cron-job.org.
Why
How
The new endpoint is not meant for normal users to query, instead, I was thinking we could use cron-job.com - A free service that can query your API.
cron-job.com waits up to 30 seconds before timeout, which is not always enough for us, which is why the generate endpoint just starts the image generation tasks, but does not await them before returning.
There is a new env variable that should be set to any random value of your liking, we just need to re-use it in cron-job.org.