vumbnail
vumbnail copied to clipboard
Method to purge cache
Hello,
I noticed that vumbnail.com caches video thumbnails using Cloudflare and Vercel with the following cache policy:
'Cache-Control': public, max-age=${ ONE_MONTH }, s-maxage=${ ONE_YEAR }
This means that thumbnails are stored for one year on Cloudflare's cache, making it impossible to refresh them if a new video thumbnail is updated.
Problem
- Adding query parameters (e.g., ?timestamp=12345) does not bypass the cache.
- Sending Cache-Control: no-cache or Pragma: no-cache headers from the client has no effect.
- Cloudflare ignores Range requests as well.
The only way to get a fresh thumbnail is to wait for the cache expiration or manually purge it (which is not possible for users).
Example:
- Old thumbnail: https://vumbnail.com/919072679.jpg
- New thumbnail: https://vumbnail.com/919072679_default.jpg
Suggested Solutions
Would it be possible to implement a method to force a cache refresh? Here are some potential solutions:
- Support cache-busting query parameters (e.g., https://vumbnail.com/919072679.jpg?v=timestamp) to serve fresh thumbnails when needed.
- Reduce the Cloudflare/Vercel cache duration (s-maxage) to a more reasonable time (e.g., a few days).
- Provide an endpoint to purge an image from the cache when necessary.
- This would be very helpful for users who frequently update video thumbnails on Vimeo.
Thanks for your work on vumbnail! Looking forward to your feedback.
Best, Louis
That makes sense why people are having so much trouble cache busting.
The tricky part is that the app is serving almost 100m thumbnails a month now so I definitely want to be careful not to mess up the cache and get a huge bill.
I've thought about a query string but it's a bit of boy scouts honor that it won't be used all the time/in prod. Maybe, I could just enable it until someone abuses it too much.
I've thought about setting up a dedicated page with a captcha connected to the Cache API for flushing thumbnails one at a time.
Another option could just be setting up paid accounts with better cache controls so that people can serve as fast as their hearts desire.