pull down to refresh
Why not just cache the generated images but still generate them on demand?
btw, I am doing the exact same thing on bitcoininflationindex.com. I use netlify for my frontend and use their "On-demand builders" to generate images which are cached on the edge.
https://docs.netlify.com/configure-builds/on-demand-builders/
Works perfect for this use-case. You could spin up a netlify microservice specifically for this purpose and run it separate from the site.
Here is my code for reference: https://gist.github.com/theshanergy/42fd16010cc968b47f93df1a5413a6f1
That’s an option I’m thinking about. I don’t use netlify but I could do something like this with AWS lambda.
deleted by author
deleted by author
deleted by author
Alternatives ...
- I still do it on demand but cache the result in block storage where it goes stale after some period of time
- I spin up a server dedicated to taking these screenshots on demand
deleted by author
deleted by author
Working on social media previews today. Currently when twitter/telegram/mastodon/etc request the little page preview I spin up a headless chome browser and screenshot the page - all inline and on demand. This has problems:
For awhile, this was DOSing SN until I put a rate limiter on it. That's not ideal though because:
Instead what I want to do is transactionally queue a job to screenshot the page every time a post/page is updated, store the image in block storage (e.g. S3), and serve that. One problem with this is determining when to screenshot non-post pages like the homepage, recent, user profiles, top, etc. I guess I can daily screenshot those pages but it's relatively inelegant.