{"id":732,"date":"2024-05-07T11:42:21","date_gmt":"2024-05-07T11:42:21","guid":{"rendered":"https:\/\/kb.shortpixel.com\/docs\/can-i-use-shortpixel-adaptive-images-with-cloudflare\/"},"modified":"2025-08-27T08:44:46","modified_gmt":"2025-08-27T08:44:46","password":"","slug":"can-i-use-shortpixel-adaptive-images-with-cloudflare","status":"publish","type":"docs","link":"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/can-i-use-shortpixel-adaptive-images-with-cloudflare\/","title":{"rendered":"How to use Cloudflare with ShortPixel Adaptive Images"},"content":{"rendered":"<div class=\"callout-yellow\">\n<h2>Read this information first<\/h2>\n<p>If you have enabled WebP and\/or AVIF in the plugin settings<\/p>\n<p><img decoding=\"async\"  src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-EJT8rfYxZ8.jpg\" style=\"width: 100%; max-width: 100%; \" \/><\/p>\n<p><b>and <\/b>are using Cloudflare&#39;s free plan, there may be problems with serving the correct format for browsers. This is because your CDN must support the <code class=\"inline-code\">Vary<\/code>  header (which is not available in Cloudflare&#39;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&#39;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 <code class=\"inline-code\">Accept<\/code>  header sent by the browser.<\/p>\n<p>To solve this problem, you have three options:<\/p>\n<ol>\n<li>Either purchase a plan from Cloudflare and <a href=\"https:\/\/blog.cloudflare.com\/vary-for-images-serve-the-correct-images-to-the-correct-browsers\/\" target=\"_blank\" rel=\"noopener\">configure the Vary header appropriately<\/a>,<\/li>\n<li>or disable <b>both<\/b> formats, WebP and\/or AVIF,<\/li>\n<li>or simply use ShortPixel&#39;s default CDN, which is among <a href=\"https:\/\/www.cdnperf.com\/\" target=\"_blank\" rel=\"noopener\">the fastest in the market<\/a>.<\/li>\n<\/ol>\n<\/div>\n<p>\n\t<em><a href=\"https:\/\/help.shortpixel.com\/article\/258-cdn-via-cloudflare-for-websites-hosted-at-siteground-it-this-possible\" rel=\"noopener\"><\/a><\/em>If you want to use Cloudflare as your CDN when&nbsp;using <a href=\"https:\/\/wordpress.org\/plugins\/shortpixel-adaptive-images\/\" rel=\"noopener\">ShortPixel Adaptive Images<\/a>, instead of ShortPixel&#8217;s CDN, follow these steps:<\/p>\n<ol>\n<li>\n<p>Log in to your Cloudflare account.<\/p>\n<p>Select your website and then the\u00a0<strong>DNS<\/strong>\u00a0section from the side menu.<\/p>\n<p><img decoding=\"async\"  src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-4V9e9DufEv.jpg\" style=\"width: 364.333px; max-width: 100%; \" \/><\/p>\n<p>Think of a name for the subdomain from which you want the images to be delivered. For example, if your domain is mywebsite.com, you could choose <code class=\"inline-code\">img<\/code> .mywebsite.com.<\/p>\n<p>Following the previous example, add a new <strong>CNAME<\/strong> record\u00a0from <code class=\"inline-code\">img.mywebsite.com<\/code>  to <code class=\"inline-code\">no-cdn.shortpixel.ai<\/code> :<\/p>\n<p><img decoding=\"async\"  src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-JUONUZUp2q.jpg\" style=\"width: 100%; max-width: 100%; \" \/><\/p>\n<p>Remember that <code class=\"inline-code\">img<\/code> \u00a0should be changed to something else if it&#39;s already used by another CNAME, like <code class=\"inline-code\">images<\/code> .mywebsite.com or <code class=\"inline-code\">media<\/code> .mywebsite.com<\/p>\n<div class=\"callout-red\">\n<p><strong>The small cloud must be orange<\/strong>\u00a0in order for you to use the CDN features offered by Cloudflare.<\/p>\n<\/div>\n<p><strong>Wait 5 minutes<\/strong> for Cloudflare to complete all the technical tasks in the background.<\/p>\n<p>Take any image URL from your site, append it to <code class=\"inline-code\">https:\/\/img.mywebsite.com\/spai\/q_lossy+ret_wait\/<\/code>  \u00a0and make sure that the new URL can be accessed. Example:<\/p>\n<ol>\n<li>If your website is called mywebsite.com, your new CNAME on Cloudflare is <code class=\"inline-code\">img.mywebsite.com<\/code> , and your sample image is <code class=\"inline-code\">https:\/\/www.mywebsite.com\/wp-content\/uploads\/2022\/04\/image.jpg<\/code> ,<\/li>\n<li>try calling this URL: <code class=\"inline-code\">https:\/\/img.mywebsite.com\/spai\/q_lossy+ret_wait\/https:\/\/mywebsite.com\/wp-content\/uploads\/2022\/04\/image.jpg<\/code> <\/li>\n<li>\n<p>Can you view it without errors? Continue with the next step.<\/p>\n<p>Go to\u00a0Settings &gt; ShortPixel AI &gt; Behaviour and enter <code class=\"inline-code\">https:\/\/img.mywebsite.com\/spai<\/code>  in the <strong>API URL<\/strong>\u00a0field<\/p>\n<\/li>\n<li>Replace <code class=\"inline-code\">mywebsite.com<\/code>  \u00a0with your <strong>actual domain<\/strong> name.<\/li>\n<li>\n<p>Replace the <code class=\"inline-code\">img<\/code>  \u00a0part if your subdomain is different, like configured above.<\/p>\n<p><img decoding=\"async\"  src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-an7VidLp8x.jpg\" style=\"width: 688px; max-width: 100%; \" \/><\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>Clear the CSS cache from the WordPress Toolbar (only relevant if you have enabled the &quot;Replace in CSS files&quot; option in ShortPixel AI&#39;s settings):<\/p>\n<p><img decoding=\"async\"  src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-zo67psWg1R.jpg\" style=\"width: 100%; max-width: 100%; \" \/><\/p>\n<p><\/li>\n<li>Clear your WordPress cache: <a href=\"https:\/\/shortpixel.com\/knowledge-base\/article\/426-how-to-clear-wordpress-cache\" rel=\"noopener\">How to clear WordPress cache<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Read this information first If you have enabled WebP and\/or AVIF in the plugin settings and are using Cloudflare&#39;s free plan, 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&#39;s free plan) and be configured to deliver [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[35],"glossaries":[],"doc_tag":[],"class_list":["post-732","docs","type-docs","status-publish","hentry","doc_category-shortpixel-adaptive-images"],"blocksy_meta":[],"year_month":"2026-04","word_count":457,"total_views":"1988","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin","author_nicename":"admin_mdli53m5","author_url":"https:\/\/kb.shortpixel.com\/author\/admin_mdli53m5\/"},"doc_category_info":[{"term_name":"ShortPixel Adaptive Images","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/shortpixel-adaptive-images\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/comments?post=732"}],"version-history":[{"count":1,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/732\/revisions"}],"predecessor-version":[{"id":2562,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/732\/revisions\/2562"}],"wp:attachment":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/media?parent=732"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_category?post=732"},{"taxonomy":"glossaries","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/glossaries?post=732"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_tag?post=732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}