Best practices for serving assets with microservice architecture

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [ x] Documentation issue or request

Current behavior

I have an instance of the squidex CMS hosted with docker and some static content(HTML) to retrieve it. Within HTML there are also links to the assets, which are stored inside the CMS.
I want to use Squidex with an microservice architecture and created a cms-service, that is between the frontend and the CMS. The purpose of that cms-service is to handle authentication for the clients and only allows indirect communication from frontend to the CMS for higher security.
So everything works well with that approach, the frontend gets the content from CMS through cms-service and renders it.

Now the problem:
The links inside the HTML retrieved form CMS contains the links to the assets and the frontend directly fetches them from the CMS bypassing the cms-service.

Expected behavior

I want to fetch the asset content for the frontend only through the cms-service.
My idea was to store the assets at the cms-service and let the frontend fetches them from the cms-service, considering that there will come a huge amount of data together.

Is there any best practice how to handle it properly for that approach or anyone faced the same questions and got an solution for that?

Environment

App Name:
test-cms

  • [ x] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]

Browser:

  • [ x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ x] Firefox
  • [ x] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

Hi,

I am pretty sure that a microservice will not give you any performance improvements when you deal with assets. I would consider a CDN or just serve from squidex directly.

Can you not just solve that problem with a simple string-replace?

Hello thanks for your answer,
i think a CDN is a good idea, because it’s then decoupled from the CMS.
The main thing is to achieve, that the frontend does not know anything about CMS and can not directly communicate with the CMS.
String-replace is also a considerable option. You mean that the cms-service fetches the wanted asset from CMS after creating the endpoint based on the information passed from the frontend?

I mean after in your service, you can just make the string replace on rich text content, just

richText = richText.replace('https://squidex.mydomain/api/assets/my-app', 'https://cdn.mydomain')