-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Clear and concise description of the problem
I would like to have the option to control cache headers for source code that doesn't change often, so I can more aggressively cache chunks of my application while developing, without using Cache-Control: max-age=31536000,immutable
.
Suggested solution
Today, Vite divides code into 2 categories - dependencies, which are pre-bundled and strongly cached, and source code which is never cached.
I'd like to propose a solution - allow users to set stale-while-revalidate cache headers for files that are known to change seldom.
This way we rip the benefits of all sides. With a small enough max-age
we can ensure the browser almost always requests fresh content in the background, but the initial load is still super fast thanks to using the now-stale files.
Alternative
An alternative solution would be to use the optimizeDeps.include
option in Vite's config, but I believe it some-what defeats the purpose.
Additional context
Large applications can contain thousands of modules, not all of which update frequently.
This causes initial (and sometimes subsequent) refreshes to be rather slow, taking sometimes as much as 30 seconds before the page is fully loaded.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.