知识卡片

普通读书笔记卡 · 3437.a.2

PUT全量替换PATCH局部改

理解等级:中级

PUT 更新按完整资源表示进行替换;PATCH 只发送要修改的部分,因此载荷可能更小,但处理逻辑也可能更复杂。书中 JSON Patch 示例用操作类型、目标路径和新值描述修改。选择哪种更新方式需兼顾客户端传输量和服务端处理成本。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 4 章《Principles of REST API design》(源文件:_epub-src/OEBPS/Text/04.htm) - 结论依据:原文对比 PUT 全量表示与 PATCH 变化属性,说明 PATCH 较小但处理复杂,并列出 JSON Patch 所需的操作、路径和值。 - 原始内容:While PUT requires the API client to send a whole new representation of the resource (hence the replacement semantics), PATCH allows you to send only those properties that changed. ... PATCH requests are more optimal, since the payloads sent to the server are smaller. However, as you can see in the following example, PATCH requests also have a more complex structure, and sometimes they’re more difficult to process in the backend: