Giter VIP home page Giter VIP logo

Comments (3)

guguji5 avatar guguji5 commented on August 10, 2024
<script type="systemjs-importmap" src="https://storage.googleapis.com/vue.microfrontends.app/importmap.json"></script>

is there any cache strategy for this link ?

from root-config.

joeldenning avatar joeldenning commented on August 10, 2024

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.

guguji5 avatar guguji5 commented on August 10, 2024

Got it, thank you for your patient and detailed answer.

from root-config.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.