Server side caching of PHP readfile images

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

  1. Is there any better approach to this only with Apache rewrite.
  2. How does Facebook deliver all images effectively with php ? There url are something like this
  3. will server side caching in binary format help ? To me this should not affect much as readfile of an image or cached file will still read a particular file (cached file instead of image !)

Source: .htaccess

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.