取消订阅链接是否需要幂等?

发布于 2024-11-28 14:01:27 字数 1459 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧故 2024-12-05 14:01:28

在这种情况下,幂等意味着无论您点击链接多少次,它都会做同样的事情,即取消订阅您。有一些解决方案会在您返回时重新订阅您,这是一种触发器方法,即非幂等。您是否将其实现为立即取消订阅(我的首选方法是,作为有足够动力点击链接的用户,我确信这就是他们想要做的)或带有确认的页面,这取决于您。只需确保无论用户点击您的链接多少次并完成该过程,他们最终仍然从您的列表中取消订阅。

Idempotent means, in this context, that no matter how many times you click on the link it will do the same thing, i.e. unsubscribe you. There have been some solutions that will resubscribe you if you return, a kind of flip-flop approach, i.e. non-idempotent. Whether you implement this as an immediate unsubscribe (my preferred approach as a user who's motivated enough to click the link is sure that's what they want to do) or a page with a confirm is up to you. Just make sure that no matter how many times a user clicks your link and completes the process that they are, at the end of it, still unsubscribed from your list.

狂之美人 2024-12-05 14:01:28

有趣的问题不是它是否幂等,而是它是否安全。它不是,因此简单的 GET(例如,可能是预取的)是错误的。

The interesting question is not whether it's idempotent, but whether it's safe. It is not, thus a simple GET (which, for instance, might be prefetched), is wrong.

烏雲後面有陽光 2024-12-05 14:01:27

我想说 RFC2616 第 9.1.2 节并不重要说,因为你已经违反了第 9.1.1 节中更重要的定义:

特别是,已经建立了 GET 和
HEAD 方法不应该具有采取行动的意义
除了检索之外。

想象一下网络爬虫(例如,Google)跟踪包含此链接的网页之一中的所有链接的效果。您真的希望这会导致取消订阅操作吗?这肯定会是一个糟糕的用户体验!

I'd say it doesn't matter what RFC2616 section 9.1.2 says, because you're already violating the much more important definition in seciton 9.1.1:

In particular, the convention has been established that the GET and
HEAD methods SHOULD NOT have the significance of taking an action
other than retrieval.

Imagine the effect of a web-crawler (e.g., Google) following all the links from one of your pages that contains this link. Do you really want that to cause an unsubscribe operation? That would certainly be a bad user experience!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文