faster fopen or file_get_contents?

前端 未结 2 1989
太阳男子
太阳男子 2021-02-14 03:41

i am running multiple websites with high traffic , as a requirement , all images are downloaded via image.php?id=IMAGE_ID_HERE . If you ever done that before , you

2条回答
  •  伪装坚强ぢ
    2021-02-14 03:44

    Why dont you cache the image content with apc ?

    if(!apc_exists('img_'.$id)){
        apc_store('img_'.$id,file_get_content(...));
    }
    
    echo apc_fetch('img_'.$id);
    

    this way image content will not be read from your disk more than once.

提交回复
热议问题