I am trying to re-design the flow we currently have in the app, where GET /image/123
endpoint would download image from Azure Blob Storage and serve it back to the client to use SAS tokens to offload our BE.
Initially I tried doing it in a way that the endpoint simply redirects clients to the right SAS token, but unfortunatelly this was causing CORS errors on the client side, as the redirect was moving the client to the different domain.
I then switched to another approach, where GET /image/123/url
endpoint would give SAS token to the client, so it can load the image, the problem is that in my initial approach I was easily able to provide client-side cache for the images using cache-control header, but this time I don't know how to do it, since the client is calling Azure directly and as a result it re-downloads the image every time.
I tried applying cache-control on the /image/:imageId/url
endpoint, so it generates SAS tokens once in a while (making sure tokens expiration is longer than the cache duration) and that works, but the client is still downloading the same image multiple times.
Is there any way I can make it work, or my approach is wrong and there are some other ways of doing that?
Thanks!