producthunt / ShareMeowClient

A Ruby client for ShareMeow :heart_eyes_cat:
MIT License
12 stars 2 forks source link

What's the recommended way to pre-generate an image when using a CDN? #4

Closed marckohlbrugge closed 8 years ago

marckohlbrugge commented 8 years ago

Generating images on-the-fly is great, but can be a little bit slow at times. Using a CDN helps, but not for the initial request.

Is there a recommended way to 'ping' the ShareMeow app through the CDN (e.g. a simple GET request) so it starts generating the image and can be loaded from the CDN cache the next request?

A simple open(url) would work, but for large images it seems wasteful waiting for the full response.

mscoutermarsh commented 8 years ago

Hey!

Hmm, not sure. I think you'd have to do the full open(url) for the cdn to cache it. Probably best to have it happen in a background job.

Other issue with that is, that cdn's typically cache per datacenter/zone. So even if you do that. It's probably only then cached in the datacenter nearest to the server that you had ping the image.

On Product Hunt we have a little loader as the div background (that contains the image). Typically see it generate in less than 1.5 seconds. Example here: https://www.producthunt.com/tech/1password-6-2-for-ios (login with twitter, click TWEET under a comment).

marckohlbrugge commented 8 years ago

Thanks. I like the idea of using an animated GIF as the background image. Clever solution that requires no additional markup. 👌