Loading images from Anvil App Assets versus from a webhost

Hello Friends:

I find it interesting that an image loaded from:

  • _/theme/MYIMAGE.jpg (App Asset URL)

loads noticeably slower than the same from one of my webhosts:

  • https://example.com/MYIMAGE.jpg

Perhaps community friends have insight as to why. Could be CDN (mine uses CloutFlare), or other factors. I prefer using the former since it’s neatly package in the Anvil App.

Thank you!

I have never done any performance tests, this is just a feedback to let you know my approach.

My guess is that any cdn with server distributed around the world and specialized to do one thing only is going to be faster than Anvil.

I use the assets only for logos and a little more. I have one app with those images and all the apps use the same url, the url of that app.

For apps that use a larger number of images I store them in datatables, so they don’t make the app larger and can be uploaded and managed by scripts.

1 Like

Your reasoning about CDNs performing better sounds about right.

Incidentally, my example was just an App landing page image. :relaxed:

But, when logged in, my App too dynamically loads images from Data Tables as the code fetches them (and those are larger and there are many that can be fetched, though never all at once - as needed).

One follow-up question to what you mentioned: When fetching resources from that separate App, how are you fully-qualifying the URL to the specific resource (an image or whatever) that you need?

By the way if you want to load images faster, you can use external services like Imagekit/Cloudinary. Both of them have generous free plans that may be enough for your needs.

Both of them have apis available. You can integrate them into your anvil app to allow uploading images to their servers from file loader and then storing the url of that images in your data tables.

They have multiple servers distributed across the world and most importantly they automatically compress images based on the network so they are naturally much faster.

3 Likes

I’m using one app as my poor-man-cdn, I always put the absolute url of the app with the logos.

2 Likes

Hi @divyeshlakhotia
Thank you for that tip. I wasn’t aware of them, and will seriously check them out. :blush: