doupoji3856 2016-02-19 19:08 采纳率: 100%
浏览 51

当两个发布请求到达服务器时,处理php中的重试发布请求

Users of my php application sometimes accidentially submit messages or other actions twice without wanting to. This seems to be an issue caused by (mobile) clients automatically retrying a request if the response takes too long, e.g. due to bad network connection. My server though handles both requests and processes them as seperate actions.

How can I handle such retry post requests without disabling the possiblity of sending deliberate double post requests? Therefore how can i distinguish between these retries and deliberatly user-send resends of the same request?

A bit of context, that could help understand the problem: I'm running a oldschool html-based browser game. Users may want to resend the exact same action like "attack" multiple times through page refresh delibaretly and I do not want to cut this option, as it's really convenient. But I want to prevent unintended double actions through clients automatically sending post requests twice without asking the user first. I'm not entirely sure if its a mobile browser specific problem.

  • 写回答

2条回答 默认 最新

  • dsa88885555 2016-02-19 21:26
    关注

    You are focussing on the wrong end of the problem. If users are sending the post twice then its probably because they are not seeing a response at their end. Yes, you still need to plan for and handle the problem serverside, but addressing it on the client will not only reduce the number of occurrences getting back to your server, but also improving the user experience.

    A real-time update at the front end means JavaScript. Also, when you're working with touch devices there is, by default, a latency of around a third of a second unless you explicitly disable some of the touch functionality.

    评论

报告相同问题?

悬赏问题

  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。