知识卡片
最近使用链接减少查找
把所有动作都移到额外资源会增加查找往返,可用最近访问入口补足常用路径。
服务可记录最近访问链接,在响应中返回少量MRU入口,帮助消费者发现常用动作,也减少为寻找动作而多请求一次related资源。可按服务或用户维护固定长度历史。
返回前要按当前权限与服务状态过滤,过去可用不代表现在可用。通常仅保存并返回URL即可,不应试图从头部推导用户意图;简短链接比完整表单成本低。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 超媒体工作流 · 查看原书依据
Keeping track of MRUs for a context (service wide or consumer specific) takes a bit of work but is not very complicated. A history list of the recently requested resources is all that is needed. As each resource is requested, that link is placed in a list (URL and count).
参考来源
- 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第7章《超媒体工作流》§7.9(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch07.xhtml)
- 结论依据:原文以服务可记录最近访问链接,在响应中返回少量MRU入口,帮助消费者发现常用动作,也减少为寻找动作而多请求一次related资源的方式说明该用途;同节示例与讨论补充了卡内条件和边界。
- 原始内容:Keeping track of MRUs for a context (service wide or consumer specific) takes a bit of work but is not very complicated. A history list of the recently requested resources is all that is needed. As each resource is requested, that link is placed in a list (URL and count).