Skip to content

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Sep 26, 2025

@eps1lon eps1lon force-pushed the sebbie/09-26-docs_for_cachesignal_ branch from cea9190 to c832b32 Compare September 26, 2025 12:54
Copy link

github-actions bot commented Sep 26, 2025

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

One Page Changed Size

The following page changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/[[...markdownPath]] 130.48 KB (🟡 +13 B) 241.02 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

eps1lon and others added 2 commits September 26, 2025 17:47
Co-authored-by: Sebastian Markbåge <sebastian@calyptus.eu>
Co-authored-by: Sebastian Markbåge <sebastian@calyptus.eu>

<Intro>

`cacheSignal()` returns an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) which aborts when the cache lifetime is done based on the same execution scope as a [`cache()`](/reference/react/cache)ed function
Copy link
Member

@rickhanlonii rickhanlonii Sep 27, 2025

Choose a reason for hiding this comment

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

This needs to be explained simple enough to fit on one line in desktop. Something like:

`cacheSignal` allows you to know when a `cache()` is cleared.

Copy link
Member Author

@eps1lon eps1lon Sep 28, 2025

Choose a reason for hiding this comment

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

Suggested change
`cacheSignal()` returns an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) which aborts when the cache lifetime is done based on the same execution scope as a [`cache()`](/reference/react/cache)ed function
`cacheSignal` allows you to know when the `cache()` life time is over.

```js {3,7}
import {cacheSignal} from 'react';
async function Component() {
await fetch(url, { signal: cacheSignal() });
Copy link
Member

Choose a reason for hiding this comment

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

This example doesn't make sense because you have no idea that the fetch here is using cache().

Can you use something like a DB example, like here?

https://react-do5kq6ru7-fbopensource.vercel.app/reference/react/cache#preload-data

Copy link
Member Author

@eps1lon eps1lon Sep 30, 2025

Choose a reason for hiding this comment

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

You don't need to know if the call is cached or not. Just that it may be cached by cache().

@rickhanlonii rickhanlonii mentioned this pull request Sep 30, 2025
6 tasks
@rickhanlonii rickhanlonii merged commit 3f0235b into reactjs:main Oct 1, 2025
6 checks passed
@eps1lon eps1lon deleted the sebbie/09-26-docs_for_cachesignal_ branch October 1, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants