{"id":799,"date":"2024-05-07T11:43:32","date_gmt":"2024-05-07T11:43:32","guid":{"rendered":"https:\/\/kb.shortpixel.com\/docs\/how-to-flush-cdn-cache-for-autoptimize\/"},"modified":"2025-08-27T08:42:57","modified_gmt":"2025-08-27T08:42:57","password":"","slug":"how-to-flush-cdn-cache-for-autoptimize","status":"publish","type":"docs","link":"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/how-to-flush-cdn-cache-for-autoptimize\/","title":{"rendered":"How to flush the CDN cache for Autoptimize"},"content":{"rendered":"<section class=\"callout-yellow\">\n<p>\n\t<strong>Note<\/strong>: If you want to flush the cache for a specific image (not all), please refer to <a href=\"https:\/\/help.shortpixel.com\/article\/237-how-to-flush-an-image-fromshortpixel-cdn\" target=\"_blank\" rel=\"noopener\">this article<\/a>.<\/p>\n<\/section>\n<p>\n\t If you want to flush the whole ShortPixel&#8217;s CDN cache for a WordPress website using Autoptimize with the image optimization option turned on, here&#8217;s how you can do it:<\/p>\n<ol>\n<li>Install and activate a code snippet plugin such as <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"noopener\">this one<\/a>.<\/li>\n<li>Navigate to <strong>Snippets &gt; Add New<\/strong>.<\/li>\n<li>Give the snippet a name and copy-paste the code snippet below.<\/li>\n<li>Below the code, choose &#8220;<b style=\"background-color: initial;\">Only run on site front-end<\/b>&#8220;.&nbsp;This will replace all the instances of the CDN URL from <code>sp-ao.shortpixel.ai\/client\/<\/code> to <code>sp-ao.shortpixel.ai\/client2\/<\/code> . The effect of this operation is to actually flush the CDN cache.<\/li>\n<\/ol>\n<pre>add_filter('autoptimize_html_after_minify','change_shortpixel_client', 11, 1); \nfunction change_shortpixel_client( $HtmlIn ) {     \n\treturn str_replace( 'sp-ao.shortpixel.ai\/client\/', 'sp-ao.shortpixel.ai\/client2\/', $HtmlIn ); \n}\n<\/pre>\n<p>\n\t<img decoding=\"async\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-WUU1Kdbhgt.jpg\" style=\"width: 890px;\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Note: If you want to flush the cache for a specific image (not all), please refer to this article. If you want to flush the whole ShortPixel&#8217;s CDN cache for a WordPress website using Autoptimize with the image optimization option turned on, here&#8217;s how you can do it: Install and activate a code snippet plugin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[36],"glossaries":[],"doc_tag":[],"class_list":["post-799","docs","type-docs","status-publish","hentry","doc_category-autoptimize"],"blocksy_meta":[],"year_month":"2026-05","word_count":146,"total_views":"4750","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":"Autoptimize","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/autoptimize\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/799","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=799"}],"version-history":[{"count":1,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/799\/revisions"}],"predecessor-version":[{"id":2466,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/799\/revisions\/2466"}],"wp:attachment":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/media?parent=799"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_category?post=799"},{"taxonomy":"glossaries","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/glossaries?post=799"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_tag?post=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}