Reputation: 18899
When we use lazy-loading for downloading specific web modules, e.g.:
import('./polyfills').then(render);
Will the browser cache these dynamically loaded files and does webpack use the cached version on subsequent requests?
With bundle splitting I know the browser will cache the loaded files; I assume this should be the same for code splitting, but I'm not sure.
Upvotes: 4
Views: 588
Reputation: 11610
Cache-Control
response header specifies if and for how long a resource can be cached. Your server is responsible for setting it.
When webpack-generated code encounters a dynamic import, it fetches and then executes it. Whatever is exposed by the module is then available as long as the page isn't closed/reloaded and when the same import is encountered again those in-memory bindings are used (the module isn't refetched or executed again).
Upvotes: 1