Comments (3)
is there any cache strategy for this link ?
from root-config.
You can control caching of the import map and other files with a cache-control header in the server response. Here are the cache-control headers I usually set:
importmap.json: Cache-Control: public, must-revalidate, max-age=0
. (Example)
All other javascript files: Cache-Control: public, max-age=31557600
^ This means the user always has to redownload the import map (to get the latest deployment), but doesn't have to redownload the javascript files themselves.
Alternatively, you can cache importmap.json for a short period of time, which means it will be faster but deployments won't take effect for a while.
And the most performant alternative is actually to inline the import map into your HTML file. This means that you must have a dynamic web-server that can modify the HTML response that is sent to the browser. The dynamic web server polls the import map once every 30 seconds, and then injects it into the HTML that is sent to the browser. That way, the browser does not even have to request the import map.
One thing to note: if you are using import-map-deployer, it often will automatically set the Cache-Control header for the importmap.json file. See these examples (1, 2) which shows that it does so for some of the io-methods.
Let me know if you have other questions!
from root-config.
Got it, thank you for your patient and detailed answer.
from root-config.
Related Issues (8)
- If gzip setting turn on, the loading will be faster. HOT 1
- Is that dynamic inject DOM problems?? HOT 1
- How to deploy in iis as application both root and child app HOT 5
- Incorrect screenshot In root MFE, about mapping
- 【utility】How to use utility correctly
- Can you add a react subproject case? HOT 1
- failed when directly call appX/:named HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from root-config.