0

When creating Twitter Apps. Most apps, will hotlink Twitter profile photos. But if a page is displaying several 20-40 profile image photos. Firebug (network tab) reports all these photos taking up 30-50 ms (each) to load. Sum that all up, and you get a few seconds.

For page rendering and optimization purposes. Should Twitter profile photos be cached/stored on the local server?

On a side-note. I understand the challenges of outdated photos (since they will be cached). But that isn't the point right now.

Christian Fazzini
  • 19,613
  • 21
  • 110
  • 215

1 Answers1

1

How do you see caching them on the local server reducing the number of network requests?

If you do cache them on the local server then you still need to serve them out to the clients, in that situation you could in-line the images to reduce the number of requests but that increases download size and destroys caching.

One advantage of retrieving them from twitter is they'll come from twitter's CDN so will probably have lower latency than serving them yourself.

Andy Davies
  • 5,794
  • 2
  • 26
  • 21
  • Would caching (via memcache or other solution) make more sense? So it doesn't have to hit Twitter's CDN. It takes roughly 50ms for each profile photo to load. 40-60 profile photos computes to a few seconds. – Christian Fazzini Feb 25 '13 at 20:56
  • If you cache them yourself how are you going to deliver them to the client - Are you going to have each photo download individually or are your going to covert to base64 and embed as a dataURI? If you are still download the photos individually then what gain will there be over Twitter doing this? – Andy Davies Feb 26 '13 at 23:47
  • 1
    Well, I've realized storing photos locally may have a better advantage. Linking to Twitter sometimes takes 500ms per photo (or even more), as reported via webpagetest.org. Storing locally will also give us the added benefit of more control. i.e. serving from our desired CDN's, image compression (for added performance), and CNAMEing path/to/photo/ urls for browser parallelism (http://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser) – Christian Fazzini Jul 03 '13 at 06:18