casual-simulation / casualos

Casual Open Simulation for the Web
https://ab1.bot
MIT License
48 stars 9 forks source link

Improve performance for loading insts when `VM_ORIGIN` is set #406

Open KallynGowdy opened 6 months ago

KallynGowdy commented 6 months ago

It is possible to set the VM_ORIGIN environment variable to a value that contains a special {{inst}} parameter which customizes the domain that the inst data is loaded in. This is great because it enforces isolation between insts, but it also means that scripts and other resources cannot be cached between insts.

This issue is to track an enhancement to how scripts are loaded where the CasualOS main-thread can load the scripts and pass them through to the inst VM, which can execute the JavaScript code. This would allow scripts to be loaded nearly instantly, as they would not require additional network requests if they are cached by the service worker.