HTTP cache invalidation: sub-resource collections need an extension point
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 68/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
调研方向
首先阅读现有的 PurgeHttpCacheListener 实现和 Serializer\TagCollectorInterface,然后检查 src/HttpCache/ 区域以及 Symfony 和 Laravel 的 wiring。完成的标准是:新的 provider interface 可用,可选 provider 被聚合并由两个 listener 查询,yield 的标签被追加,并且该扩展接缝有文档说明。
由索引模型根据 Issue 内容生成。
描述
Problem
PurgeHttpCacheListener (Symfony Doctrine and Laravel Eloquent) cannot invalidate sub-resource collection operations such as /parents/{parentId}/children. Resolving the IRI requires parent uriVariables that the listener does not have when it sees the modified entity, so those collection tags are silently skipped.
Pragmatic solution
Expose a public extension point — symmetric to Serializer\TagCollectorInterface on the response side — that the listener consults to collect extra tags for a given entity:
namespace ApiPlatform\HttpCache;
interface PurgeTagProviderInterface
{
/**
* @return iterable<string> additional cache tags to invalidate for $entity
*/
public function getTagsForResource(object $entity): iterable;
}
Wiring:
- Tagged service (Symfony) / iterator binding (Laravel), aggregated and injected into
PurgeHttpCacheListener. - The listener appends whatever the providers yield to its existing tag set.
- Default ships with no provider — users opt in.
This keeps identifier-finding out of the framework (the user knows how their child invalidates their parents) and lets each project plug exactly the strategy that fits its routing (parent uri_variables, surrogate-key prefixes, class-based tags, etc.).
Scope
- Add the interface in
src/HttpCache/. - Inject
iterable<PurgeTagProviderInterface>(optional, default empty) into both Symfony and LaravelPurgeHttpCacheListener. - Document the seam alongside
TagCollectorInterface.
- 主要语言
- PHP
- 星标
- 2.6k
- 派生
- 989
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 81
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
api-platform/core 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
api-platform/core#8665 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
api-platform/core#8660 · 1 条评论 ·
维护者通常 1 天内回复
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1未关闭
难度 2/5 1-3 小时 新手友好度 76/100
api-platform/core#8650 ·
维护者通常 1 天内回复
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7未关闭
难度 2/5 1-3 小时 新手友好度 78/100
api-platform/core#8648 · 1 条评论 ·
维护者通常 1 天内回复
-
[Laravel] Optional BelongsTo relation cannot be set to null (500 on POST/PATCH)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 54/100
api-platform/core#8664 ·
维护者通常 1 天内回复
查看 api-platform/core 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
scanaislop/aislop#482 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
humanmade/publication-checklist#73 · 1 条评论 ·
-
Do not throw `WordPress.Security.EscapeOutput.OutputNotEscaped` on `apply_shortcodes()`可能已有人在做 @tbradsha 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100