nginx SSI
tselishev-semen opened this issue · 3 comments
First of all, the idea is very smart. Really enjoyed reading it.
I have a small question though regarding an env-config.js
. Why did you prefer this solution over Nginx SSI for example? When you create a small HTML template (using SSI) with injected JSON inside, like this:
<script type="application/json" id="env-config">
{
"API_URL": ""https://..."
}
</script>
and then just inject this template into index.html
.
It looks like this way you can optimize the performance of the app and resolve some issues with the cache.
- It will avoid an extra request to
env-config.js
since all data will be already insideindex.html
- no extra Round Trip for the very first-page loading - No need for cache busting approach for
env-config.js
, since you can just clean cache on the CDN for yourindex.html
when you need to change something. It's possible because HTML files are cached differently than js scripts and have minimum cache time or don't have it at all.
I used to use a similar approach, but using NGINX SSI looks like a superior solution :) Probably I'm missing something, so I would really appreciate your comment on that
It seems to be a good suggestion indeed, especially due to the mentioned points.
This post is trying to implement the most simple straightforward idea on which better production-ready solutions could be built, such as the one you suggested.
Have you tried this and it successfully worked for you?
all good, so far I have used Nginx SSI twice: for feature flags and micro frontends. Your current solution also works, I just found a reference in Module federation examples, so wanted to check how it works under the hood
@tselishev-semen , I went through your comments and it was a great suggestion.
I tried Nginx SSI, but it does not replace my index.html I am not sure what I am missing here. If possible, can you kindly help me solve this issue?
templatetest.zip