bangumi / bangumi/server

防止请求重发的中间件

Open
#233 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
679
Forks
77
Avg merge
12m
Merged PRs (30d)
7

Description

用户发送请求 A,出于某些原因超时,客户端没有接收到返回。用户选择重发请求,产生请求 B。
服务器会在某个时间范围内收到 A,B 两个一样的请求,理论上应该 drop 第二个请求。

目前似乎没有这个机制,

可以对请求的 url ,数据和用户 id,hash一下存到 redis 并设置过期时间 比如 1分钟,在接到第二个请求就直接返回错误。

> 之前甚至搞过缓存第一个请求的结果,用户在单位时间内再次请求会返回缓存的结果

前提自然是第一个请求服务器确实接收到了

ps: 当然不对 GET 请求生效

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by locating the request middleware and any existing Redis integration, then determine how requests are identified and how duplicate non-GET requests should be rejected. Done means the agreed duplicate-request behavior is implemented with an expiry window and verified by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, redis
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.