I'm having a hard time making a decision on how to handle user generated uploads without storing filename values in a database. When a user uploads say, a profile avatar/image, I create it on the CDN. My avatar helper in PHP knows the container's url so I can simply echo 'http://cdn-static-url.com/'.$userId.'.jpg
But if a user re-uploads/changes their avatar, the old image is still cached across the CDN until the TTL expires, or I send a purge request (I use Cloud Files and have unlimited purge requests, but even then, the purge is not immediate).
How should I allow for the re-upload of an image, and either;
- force the change immediately,
- alert the user of the status of the purge ("Your new image may take X amount of time to update", I've never even seen this)
- create a new object on the CDN which would mean storing the reference to the filename in MySQL (then I would be doing a SELECT every time I wanted to echo the avatar url on the page...)
- use the above and leverage Memcache for each object's current url?