xdesro / personalsit.es

📇 A little directory of people's personal sites
https://personalsit.es
691 stars 542 forks source link

Time to swap off Cloudinary #644

Open xdesro opened 1 year ago

xdesro commented 1 year ago

We've exceeded the free tier of Cloudinary lol. I think something like @11ty/eleventy-img will serve this need better. Not sure how to handle caching and re-requesting screenshots. Right now, if someone updates their site, I can just delete the image on Cloudinary and the app knows to re-screenshot.

zeroby0 commented 1 year ago

Heyo!

I'm not an expert on eleventy_img, but I did contribute a bit to it. Please feel free to tag me if you need help with anything related.

Something like a cron job (or maybe github actions or netlify functions?) that takes a screenshot would work quite nicely imo.

The files processed by eleventy_img have a hash in them, calculated from the original file's content (unless the original file is a URL). Because the hash necessarily changes when you change the original screenshot, you can cache them indefinitely in the browser with cache-control: public, max-age=31536000, immutable.

I also wrote a plugin to cache images across builds on netlify: https://github.com/zeroby0/netlify-plugin-11ty/ There's an eleventy screenshot thingy too: https://www.11ty.dev/docs/services/screenshots/

kirillunlimited commented 12 months ago

@xdesro Here is the PR with migration from Cloudinary to 11ty/api-screenshot: https://github.com/xdesro/personalsit.es/pull/738

This netlify function should be hosted as a separate project to decouple its cache from https://personalsit.es. Cache suffix is individual for each website in the list and uses .md file create date. Probably, it should be changed to Last Modified to be able to reset cache for some websites by updating their .md files if necessary.

I made my own project to handle screenshots and deployed it to netlify, but you can fork it and deploy it by yourself if you want. https://personalsites-screenshots.netlify.app https://github.com/kirillunlimited/api-screenshot

More info about 11ty/api-screenshot: https://www.zachleat.com/web/screenshots/

woodrunsdeep commented 5 months ago

Hi there! I've noticed that all images are missing right now. Not sure why though but wanted to let you know. image

xdesro commented 5 months ago

This is exactly the reason, @woodrunsdeep :D. Cloudinary killed my plan and I haven't merged in @kirillunlimited's PR just yet. Thanks for the heads up!