Can I use a different CDN with ShortPixel Adaptive Images?

ShortPixel Adaptive Images works correctly out-of-the-box, so configuring it to work with your own CDN should only be done if you have  good technical knowledge. Please consider checking how are the credits counted if you use your own CDN.

Read this information first

If you have enabled WebP and/or AVIF in the plugin settings

there may be problems with serving the correct format for browsers. This is because your CDN must support the Vary header (which is not available in Cloudflare's free plan) and be configured to deliver the original format, the WebP version and/or the AVIF version from the same URL, depending on the browser's capabilities, so that it knows (and caches and delivers accordingly) that there are two different files to deliver for the same URL, depending on the Accept header sent by the browser.

Therefore, you have three options:

  1. Either make sure your CDN supports the Vary header and is properly configured,
  2. or disable both formats, WebP and/or AVIF,
  3. or simply use ShortPixel's default CDN, which is among the fastest in the market.

If you want to use your own CDN when using ShortPixel Adaptive Images, instead of ShortPixel's CDN, follow these steps:

  1. Think of a name for the subdomain from which you want the images to be delivered. For example, if your domain is example.com, you could choose cdn .example.com.
  2. Edit your DNS records to add a CNAME from cdn.example.com to no-cdn.shortpixel.ai . This step might be slightly different depending on what CDN you use.

    Remember that example.com  should be changed to your actual domain, and that cdn  should be changed to something else if it's already used by another CNAME, like images .example.com or media .example.com

    Please contact your CDN provider if you need assistance with this step.

  3. Make sure the new record (cdn.example.com) works as expected with an online tool like whatsmydns.net.
  4. Go to Settings > ShortPixel AI > Behaviour > API URL and enter the following URL: https://cdn.example.com/spai
    1. Replace example.com with your actual domain name.
    2. Replace the cdn part if your subdomain is different, like configured above.
    3. Please note that if you're not using Cloudflare as CDN, then your CDN should be able to handle the SSL certificate so you can have the API URL with https . If they cannot handle this, a certificate error will occur and your API URL should start with http instead of https .

Examples

Here you will find instructions on how to do the previous steps for the most important CDN providers.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us