Images loading slowly on custom domain

The issue
Loading the same website on a custom domain is dramatically slower (due to image assets) compared to loading the same site on the netlify.app domain.
https://jimdixon.netlify.app/tiling (2.6MB loads in 1.72s)
https://jimdixon.co.uk/tiling (2.6MB loads in 24.97s)

An example of a slow image
a. netlify.app
https://jimdixon.netlify.app/assets/img/jim-dixon-HEMS4987-02_900w.jpg
– x-nf-request-id: 8e7570c1-2b2c-4be5-80cf-6d2fde66239e-2186002
b. on custom domain
https://jimdixon.co.uk/assets/img/jim-dixon-HEMS4987-02_900w.jpg
– x-nf-request-id: e1debdd2-2dd4-4222-91fe-fe8b3f9edd24-792349

I believe this relates to two closed threads:


@wesort Loading each version locally and through GTMetrix shows almost no different in delivery times, although you don’t seem to be using scaled images.

Hi, @wesort. I’m actually showing the other site (lifestyleprojects.com) is using Netlify DNS so that is part of the difference.

I’m going to focus on the site with the slow images on the custom domain. I also want to thank you for including the x-nf-request-ids that these make researching this much easier.

I’m seeing the custom domain jimdixon.co.uk points to our load balancer IP address:

$ dig jimdixon.co.uk  +noall +answer

; <<>> DiG 9.10.6 <<>> jimdixon.co.uk +noall +answer
;; global options: +cmd
jimdixon.co.uk.		1798	IN	A	104.198.14.52

When this is done we recommend making some subdomain (like www.jimdixon.co.uk) the primary domain for the site. This site has the apex/bare/root domain (jimdixon.co.uk) set as primary.

This means all traffic is being sent to a single IP address near San Francisco from the U.K (slow). When you use the netlify.app domain name, you get routed to an IP address in the EU (fast).

The solution for this is to make the www subdomain the primary domain for this site (under Site Name > Settings > Domain management > Custom domains).

If there are other questions about this, we’ll be happy to answer.

Edit: There is a blog post about this topic here also:

Hi @luke
– Thanks
– I have always preferenced the naked domain over the www subdomain for the sake of visual address simplicity.
– I was aware of the DNS flexibility aspect (easier to invalidate URL caches, etc), but didn’t know about the single geolocation of the IP address. Suppose that’s obvious now that I think about it.
– I’ve just swapped to the site to use www and the performance has improved.
– I’m not sure what lifestyleprojects.com has to do with this?

Hi @gregraven
– I’m not sure what you mean by ‘scaled images’.
– Are you seeing an issue with how I’ve configured srcset?

Thanks.

@wesort I was just passing along what GTMetrix reported when I ran timings for your site.

Hi there @luke,

I hope it’s ok to reply on this thread. I am facing a slow loading images problem on my portfolio. Some images are even smaller than others but take more time to load somehow. I recorded the HAR as an example (in case it would be needed)


Are the images too big ? or is it something else ?

Please do not hesitate to let me know if there are any details or info that you need so I could fix that.

Thank you in advance.

link to the website :

Hi, @manuel_dmc, it looks like you may already have made improvements.

The screenshot above also shows 25.7 MB transferred and that is likely far more data than most site would want to send for the initial site load. However, when I check the site now, the initial page load is much, much smaller at about only 1 MB currently.

My best recommendation would be to check the site using PageSpeed Insights:

Or use Lighthouse (in Chrome devtools or however you prefer):

This will highlight problem areas of the site better than I could.

If there are other questions though, please let us know.