Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

HTTP cache invalidation: sub-resource collections need an extension point

未关闭
#7,965 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@guillaumedelre 已经在做这个了。

开始于 2026年5月11日。

  • #7970 来自 @guillaumedelre —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清

调研方向

首先阅读现有的 PurgeHttpCacheListener 实现和 Serializer\TagCollectorInterface,然后检查 src/HttpCache/ 区域以及 Symfony 和 Laravel 的 wiring。完成的标准是:新的 provider interface 可用,可选 provider 被聚合并由两个 listener 查询,yield 的标签被追加,并且该扩展接缝有文档说明。

由索引模型根据 Issue 内容生成。

描述

performance

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 Laravel PurgeHttpCacheListener.
  • Document the seam alongside TagCollectorInterface.
主要语言
PHP
星标
2.6k
派生
989
平均合并
1 天 17 小时
30 天内合并 PR
81

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

api-platform/core 的其他 Issue

查看 api-platform/core 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。