duanlu0075 2013-09-24 13:10
浏览 18

PHP readfile v.Apache

I'm planning an application. The application serves a lot of images. Because I want images to be only available to those with a password and at the same time I want to avoid the hassle of htaccess and htpasswd files my plan is to store images outside the web directories and serve them using readfile.

My question is: how much of a performance difference might there be in using readfile() than having Apache serve the files directly? I just don't know enough about how Apache and PHP work to know if my plan is sensible or not.

OK. So I've done some browsing around on this site and some people do suggest using readfile() as a way of 'securely' serving images - which can now be stored outside the web root. I just have this feeling there must be other options between this and htpasswd. (Thanks for the comment below from Pekka about x-sendfile. It is just that in this case that isn't an option).

Thanks

  • 写回答

1条回答 默认 最新

  • dsc71976 2013-09-24 22:15
    关注

    The problem is i like PHP but its not the fastest programming language for such things. When you really need performance you should take a look at HipHop from Facebook to compile your files to native C.

    I don't know the size of your site but readfile() and file_get_contents() could be very slow and take a lot of memory when you have a lot of requests.

    But this is only possible when you have root access.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计