netlify / ask-netlify

A place to submit questions for Netlify to answer in tutorials, podcasts and blog posts
https://ask.netlify.com
32 stars 8 forks source link

How to stop duplication of assets with identical contents #43

Open jay-to-the-dee opened 5 years ago

jay-to-the-dee commented 5 years ago

About me

My question in a little more detail

I use GTmetrix to measure my website's performance regularly. It makes suggestions as to optimisations.

One issue I'm currently getting highlighted by the tool is "Serve resources from a consistent URL - The following resources have identical contents, but are served from different URLs. Serve these resources from a consistent URL"

I've disabled and re-enabled Netlify asset optimisation, as well as changing my jekyll-assets config to no luck. It seems that <img src> asset references are always served with the CloudFront domain, whilst <link href> references are always served off the Netlify origin domain.

Here are the extracts of the Netlify produced source code; where simpler-bulb-primary-dark.svg is the exact same resource unnecessarily duplicated by two different HTTP requests: <link rel="preload" as="image" href="/assets/simpler-bulb-primary-dark.svg"> & <img width="250" height="250" alt="Smart Helping Hands logo" src="https://d33wubrfki0l68.cloudfront.net/abdba9c31570febda716627613edee7c1b7b9338/057de/assets/simpler-bulb-primary-dark.svg" integrity="sha256-5z1P4yeVXgVsxe/bywcAGcessUwED2e8NgmMsxRhKBo=" crossorigin="anonymous">'

Is this a bug in Netlify, or is there a way of fixing this behaviour?