When you enable CDN, we exclude certain files by default from being served by the CDN:
- The robots.txt file.
- Any files in the .well-known directory.
- Any file name that contains the word “sitemap” (whether it’s at the beginning, middle, or end of the file name).
In your site’s CDN settings (WordPress Sites > sitename > CDN > Exclude files from CDN > Settings), you can configure additional directory paths, URL paths, and/or file extensions to be excluded from the CDN.
CDN Exclusion Settings
To manage your site’s CDN exclusions, click on your site in MyKinsta and go to CDN. Under the Exclude files from CDN section, click on the Settings button.
Enter the (directory) path, URL (path), or file extension you want to exclude.
- Exclude files based on directory (directory path): Enter one directory or file path at a time, relative to the public directory/folder, like /wp-content/uploads/custom-image-folder, /my-documents, or /data-feed.txt and click the Add directory button. All static assets within those directories and subdirectories (if they exist) will be excluded from the CDN.
- Exclude files based on URL (URL path): Enter the path (do not include the protocol or domain), one page at a time like /homepage, /blog/2021, or /shopping, and click the Add URL path button. All static assets on those pages will be excluded from the CDN, based on their Referer header. When a page is loaded in the browser, all subrequests for static assets have a Referer header that matches that page’s URL. Any subrequest that has an excluded URL path in its Referer header is excluded from the CDN.
- Exclude files based on type: Add one or multiple file extensions like .jpg, .jpeg, or .gif by choosing each file type from the dropdown menu and clicking the Add extension button for each extension you want to add. Any file ending in any of those extensions will be excluded from the CDN, no matter where they are located in your site files. To quickly find a file extension, you can start typing it in the field provided.
To edit the path or URL exclusions, click on the pencil (edit) icon on the right-hand side for that exclusion.
In the Edit exclusion modal/pop-up that appears, make your desired changes to the exclusion and click the Edit exclusion button to save your changes.
To delete an exclusion, click on the trash can (delete) icon on the right-hand side for that exclusion.
You can also select multiple exclusions by selecting the checkbox next to each one or check the multi-select box at the top of each exclusion list to select all exclusions in that list.
- Percent-encoding (aka URL encoding) is a method for encoding spaces and certain special characters in URLs. If needed, this is handled in the background. If you enter a URL path with spaces or other reserved characters, it will be shown in MyKinsta the way you enter it but will be stored and used with the encoded value, so it works as intended. If you’re not sure if a URL path is encoded, visit the URL of the page or asset and copy the URL path from your browser’s address bar.
- Subpaths of a directory path or URL path are excluded as well. For example, if /blog is entered, subpages like /blog/category-1 and /blog/category-1/some-post-title will also be excluded from the CDN. If you do not want those subpages to be excluded, you’ll need to enter the entire path of the page to be excluded. Entering /blog/category-2/some-title will exclude that page from the CDN, while other pages like /blog, /blog/category-1, and even /blog/category-2/some-other-title will still be served by the CDN.
- Only one path or file extension can be entered at a time.
- A single, specific file can be excluded by adding the directory path and file name to the Exclude files based on directory field.
Exclude all static assets in the /public/wp-content/my-custom-folder directory.
Add /wp-content/my-custom-folder to Exclude files based on path.
Visiting any page that loads static assets from that directory and viewing the Network tab of browser developer tools will show those static assets are bypassing the CDN.
Exclude the data-feed.txt file in the public directory.
Add /data-feed.txt to Exclude files based on directory.
Exclude all static assets on the /shop/item-1 page.
Add /shop/item-1 to Exclude files based on URL.
Visiting the https://example.com/shop/item-1 page and viewing the Network tab of browser developer tools will show all static assets loaded on that page are bypassing the CDN.
Exclude all PDF files from the CDN.
Add the PDF extension to Exclude files based on type.
Visiting any page that includes a PDF file and viewing the Network tab of browser developer tools will show that the file is bypassing the CDN.
By adding CDN exclusions, you have more fine-grained control over which files are served by CDN. For the best results, be as broad as you can with your exclusions, but be as specific as needed so you don’t accidentally exclude files that could be served by the CDN.