-1

I am using create-react-app CLI to build my application. What I noticed is that the images take longer time to load from CDN than if it is loaded from the local assets folder residing in the src folder. But everybody says that CDN is faster which I am not noticing. The same image takes 200ms to load through CDN whereas 4ms when it is from a local folder.

What do you think is the best way?

fatihyildizhan
  • 8,614
  • 7
  • 64
  • 88
PCK
  • 1,254
  • 6
  • 20
  • 37
  • I think you need to educate yourself on how CDNs work. – Ian Kemp Nov 29 '18 at 05:28
  • I may not completely know it, but I do have a basic understanding of how CDN works and that is why I am confused as to why the images are loaded faster from my assets folder. If you know the answer please do educate me or point me in the right direction, instead of being rude or downvoting my question. – PCK Nov 29 '18 at 06:25

1 Answers1

5

Files that are local will always be faster. But only for the local machine, think about it you are hosting and using the site locally and the image files are also on the machine. You have no external calls to outside sources. You could work with no internet connection.

Now if you use a CDN that needs the internet, it will go and fetch that file for you. Developing locally that will be slower. But as soon as your app is being used by clients they will need that image, getting it from your server will work, but it may be slower.

The power of a CDN is that they have are a network, they have redundancy, caching, and they have instances all over the world. It will take load of your server itself.

ICodeGorilla
  • 588
  • 1
  • 5
  • 26
  • The image takes time to load even if it is a 100kb image. It takes about some milliseconds. But even then, the rendering looks bad because of it – PCK Nov 30 '18 at 04:13