Skip to content

Respect cache directives and avoid request deduplication for unhashed assets#69302

Open
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:fix-sw/here-we-are-again
Open

Respect cache directives and avoid request deduplication for unhashed assets#69302
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:fix-sw/here-we-are-again

Conversation

@SkyZeroZx

Copy link
Copy Markdown
Contributor

fix(service-worker): avoid caching private unhashed assets

Respect Cache-Control directives for unhashed asset resources and skip CacheStorage writes for responses marked no-store or private. Evict existing unsafe cached entries before fetching from the network.

More context https://issuetracker.google.com/u/1/issues/522520490

fix(service-worker): deduplicate only hashed asset fetches

Limit URL-based in-flight request deduplication to hashed asset resources. Unhashed runtime resources may vary by session, so concurrent requests should fetch independently.

@angular-robot angular-robot Bot added the area: service-worker Issues related to the @angular/service-worker package label Jun 11, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jun 11, 2026
@SkyZeroZx SkyZeroZx changed the title fix(service-worker): avoid caching private unhashed assets Respect cache directives and avoid request deduplication for unhashed assets Jun 11, 2026
Respect Cache-Control directives for unhashed asset resources and skip CacheStorage writes for responses marked no-store or private. Evict existing unsafe cached entries before fetching from the network.
Limit URL-based in-flight request deduplication to hashed asset resources. Unhashed runtime resources may vary by session, so concurrent requests should fetch independently.
@SkyZeroZx SkyZeroZx force-pushed the fix-sw/here-we-are-again branch from 1213038 to c926c9d Compare June 11, 2026 04:38

const UNCACHEABLE_CACHE_CONTROL_DIRECTIVES = new Set(['no-store', 'private', 'no-cache']);

function hasUncacheableCacheControl(headers: Headers): boolean {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is similar to how we now handle no-cache responses in HttpTransferCache
#69017

@SkyZeroZx SkyZeroZx marked this pull request as ready for review June 11, 2026 08:49
@pullapprove pullapprove Bot requested a review from crisbeto June 11, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: service-worker Issues related to the @angular/service-worker package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant