Skip to content

feat: add cache.storeFilter for filtering cached assets #19577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cseas
Copy link

@cseas cseas commented Jun 3, 2025

Fixes #19359

What kind of change does this PR introduce?

Add a new config option cache.storeFiles which gives the users an option to configure filtering for which assets should be excluded from cache.

Did you add tests for your changes?

WIP

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

@@ -1040,7 +1040,7 @@ export interface WebpackOptions {
*/
export interface MemoryCacheOptions {
/**
* Additionally cache computation of modules that are unchanged and reference only unchanged modules.
* Additionally cache computation of modules that are unchanged and reference only unchanged modules in memory.
Copy link
Author

Choose a reason for hiding this comment

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

I didn't change this line. This was added automatically by yarn run fix:special

/**
* A function to filter which cache entries should be stored. Return false to skip storing a cache entry.
*/
storeFilter?: (identifier: string, data: any) => boolean;
Copy link
Author

Choose a reason for hiding this comment

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

Function signature is similar to the one suggested by @alexander-akait here but I'm not sure if there are any use-cases for filtering on data.

Need input from the maintainers here. If it isn't required, I'll go ahead and remove the data parameter.

@cseas cseas marked this pull request as ready for review June 3, 2025 08:17
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

It should work for memory cache too, also please add test cases

@cseas cseas marked this pull request as draft June 3, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Asset module binary files are stored in webpack cache
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy