For SEO reasons I am sending some images using PHP readfile and URL rewrite. I save images in a folder with numerical id (id.jpg) but serve the image with keywords (some-seo-word-id.jpg). While the scripts runs smoothly and show images effectively, however in pages with multiple images (5 to 6) it fails to send all images correctly. 
Refreshing the pages 2 to 3 times sometimes shows all images, sometimes it does not ! Since the max image size delivered using PHP readfile is 70-140 KB each I highly doubt that memory can be an issue. My question is 
- Is there any better approach to this only with Apache rewrite.
- How does Facebook deliver all images effectively with php ? There url are something like this https://www.facebook.com/photo.php?fbid=XXXXXXXXX27&set=a.4533609xxxx.xxxx099.xxxx210426&type=1&theater
- will server side caching in binary format help ? To me this should not affect much as readfileof an image or cached file will still read a particular file (cached file instead of image !)
