donglu5041 2015-09-03 15:32
浏览 21

使用php在服务器上显示进度的最佳方法

What are best ways to display progress on server work?

  1. xhr processing request
  2. iframe method ( i dont prefer this method )
  3. server sent events
  4. polling with some flash messages on $_SESSION variable in main php script

which is most clean and most used way?

use case is for example when we upload zip files, i want to track progress on unpacking, copying files etc

  • 写回答

1条回答 默认 最新

  • duanhuan6857 2015-09-03 15:44
    关注

    Your question is a bit vague - there is no "best" way, each one has advantages and disadvantages. Try to explain what is important to you.

    For example, the most clean, scalable and performant way would probably be to push an update on progress to the client using WebSockets. However, this may require some special implementation on the server and client side and may be a bit complex.

    On the other hand, if you want simplicity and ease of implementation and are willing to sacrifice performance and scalability, going with a $_SESSION + Ajax polling solution could be better - however you should be careful as some session storage backends lock the session which means you cannot have one PHP request updating it while another is attempting to read from it. You can instead use DB / memcache / file storage (depending on your scale needs and server setup) to store this information.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集