How to reference CDN images in a stylesheet that can use HTTPS?

I have all the settings for my image to work with Amazon Cloudfront CDN. If my pages will sometimes be served by both HTTP and HTTPS, then should I do all the paths to the HTTPS paths to the CDN?

Is this really bad practice?

Any other ideas?

+5
source share
1 answer

Creating all the image paths to a CDN over HTTPS is definitely a bad idea. Each HTTPS request has significant overhead, so you may not want to.

However, it turns out that there is a simple solution for determining absolute cross-domain URLs without a protocol. Just use something like in your css

url: (//d604721fxaaqy9.cloudfront.net/image.jpg) ...

, , , , -

<link href="/styles.css" ...

<link href="styles.css" ...

!

+2

All Articles