itsthatguy / avatars-api-middleware

The express middleware for our avatars service
http://avatars.adorable.io
Other
749 stars 96 forks source link

Cache resultant avatars for future requests #51

Closed bigtiger closed 7 years ago

bigtiger commented 8 years ago

Request came from Twitter https://twitter.com/mgmarshalluk/status/752854367578054657

Getting a delayed browser wait on the avatars, e.g. api.adorable.io/avatars/100/e8…. Can you cache them once generated? :)

itsthatguy commented 8 years ago

https://github.com/adorableio/avatars-api/tree/image_caching?files=1

mgmarshall commented 8 years ago

Hello, yes thanks for this.

Basically I am trying to use your avatars on my social site as currently we just have Gravatar, Facebook and Google.

We use a UID for each user and their avatar shows like this: https://api.adorable.io/avatars/100/e8f4a225e467d58270d48ed829615be4.png

When using it on the website, I am seeing up to a 7-8 second delay in it showing. That is with only 1 avatar on screen. If I put this live it would be dozens.

Here is the NET graph from Firebug, you can see its around 4 seconds here.

adorable1

Here is another one, on a page with lots of Gravatar requests (they are obviously blocking each other a bit)

image

Your service is completely free (and a breath of fresh air) so I understand why you would want to ignore this request. But if there is anything you can do I would love to hear it :)

Thanks

Michael

mgmarshall commented 8 years ago

I just saw the post by istthatguy who shows a diff branch, thanks man. I had no idea this was open source like this. Do you have any plans to add caching to the branch running on http://avatars.adorable.io/ ?

itsthatguy commented 8 years ago

@mgmarshall yes, we do. As soon as we get time to wrap that work up, we will get it deployed, and close this issue.

mgmarshall commented 8 years ago

Thank you very much :D

bigtiger commented 8 years ago

Throwing more heroku dynos at this lately. We're going to need to spend some cycles on this coming up. I wonder whether the db is the best layer to cache this at. If not there, then where? If we had a persistent file store we could store them as static files. idk

southpolesteve commented 7 years ago

@bigtiger Not sure what it would cost at your bandwidth, but check out the heroku fastly add on. We're big fastly users (outside of heroku). A+ would recommend. Seems like a good solution for this problem.