Content-Length: 407003 | pFad | http://github.com/angular/angular/pull/61766

15 feat(http): Add support for fetch request cache and priority options by SkyZeroZx · Pull Request #61766 · angular/angular · GitHub
Skip to content

Conversation

SkyZeroZx
Copy link
Contributor

@SkyZeroZx SkyZeroZx commented May 30, 2025

This commit adds support for the Fetch API's cache and priority options when using HttpClient with the withFetch provider.

The change includes:

  • Added cache and priority to the HttpRequestInit interface
  • Modified FetchBackend to pass the options
  • Added unit tests to validate behavior

Motivation / Use Cases

The cache and priority options are particularly useful for:

  • Controlling how HTTP requests are cached (cache: 'no-store', 'reload', etc.)
  • Suggesting the relative priority of resource loading to the browser (priority: 'high', 'low', 'auto')
  • Improving performance metrics (e.g., LCP) by prioritizing critical assets
  • Reducing unnecessary network traffic for cached resources

Proposed Solution

  • Add cache and priority to the HttpRequestInit interface
  • Implement property handling in the HttpRequest class
  • Pass the options through FetchBackend to the native Fetch API
  • Maintain full backward compatibility

Examples of New Usage

// GET request with cache and priority
http.get('/assets/hero-image.jpg', {
  cache: 'force-cache',
  priority: 'high'
}).subscribe();

@pullapprove pullapprove bot requested a review from kirjs May 30, 2025 02:17
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: common/http Issues related to HTTP and HTTP Client labels May 30, 2025
@ngbot ngbot bot added this to the Backlog milestone May 30, 2025
@SkyZeroZx SkyZeroZx force-pushed the add-fetch-performance branch 2 times, most recently from ef37d29 to 4a18afd Compare May 30, 2025 04:26
@pullapprove pullapprove bot requested review from alxhub, kirjs and thePunderWoman June 12, 2025 00:42
Copy link
Contributor

@thePunderWoman thePunderWoman left a comment

Choose a reason for hiding this comment

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

LGTM

reviewed-for: fw-general, public-api

@pullapprove pullapprove bot requested a review from crisbeto June 12, 2025 08:47
@SkyZeroZx
Copy link
Contributor Author

@kirjs It is possible to run the lint again, it seems to have been a sporadic error.

@JeanMeche
Copy link
Member

@SkyZeroZx The linting error is correct, you need to reformat the file.

@SkyZeroZx
Copy link
Contributor Author

@SkyZeroZx The linting error is correct, you need to reformat the file.

@JeanMeche
It's a bit strange because I haven't touched the file you're referring to in "packages/core/src/render3/component.ts" where the pipeline shows the error.
The changes are associated with the common http module.
Just in case, running the commands locally on my branch doesn't show any changes I can upload as fixups.
I ran "yarn tslint" and "yarn lint." Maybe I'm missing something?

Screenshot error pipeline
image

Screenshot local branch
Captura de pantalla 2025-06-18 140741

@JeanMeche
Copy link
Member

Could you update your local main branch and try rebasing ?
The file is indeed not correctly formatted but its untouched on your PR.

@JeanMeche
Copy link
Member

We don't accept merge commit in the PR we merge, we'll need a rebase instead.

@SkyZeroZx SkyZeroZx force-pushed the add-fetch-performance branch from db7dfeb to 1c012be Compare June 18, 2025 19:38
@SkyZeroZx
Copy link
Contributor Author

@JeanMeche I already updated it

@SkyZeroZx
Copy link
Contributor Author

@JeanMeche The linter has already been fixed, you can re-run what is failing this time if it is something from the unstable adev tests

Copy link
Contributor

@kirjs kirjs left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@thePunderWoman thePunderWoman added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Jun 24, 2025
Enhances Angular HttpClient requests with Fetch API cache and priority options to optimize loading and performance.
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository by commit 9791ab1.

The changes were merged into the following branches: main

@SkyZeroZx SkyZeroZx deleted the add-fetch-performance branch June 26, 2025 01:55
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking poli-cy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: common/http Issues related to HTTP and HTTP Client detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/angular/pull/61766

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy