--- title: "Clear the cache" description: "Remove files from E2E CDN's cache with Flush Cache, so visitors get the version you changed at your origin before the cached copy expires." content_type: "how-to" product: "cdn" platform: "MyAccount" url: "/myaccount/cdn/how-to/clear-the-cache/" --- # Clear the cache The CDN keeps a copy of each file at its edge locations until the file's TTL runs out. When you change a file at your origin, visitors keep getting the cached copy until then. To serve the new version sooner, clear the file from the cache with an invalidation. The next request for each file you clear is fetched from your origin. ## Before you begin Put the new version of the file at your origin first, such as in your bucket. Clearing the cache before that only fetches the old file again. ## Choose the paths You clear files by their paths on the distribution, each starting with `/`: - The root address: `/`. - One file: `/images/image1.jpg`. - Every file in a folder: `/images/*`. - Every file whose name starts with the same letters: `/images/image*`. - Every file: `/*`. A `*` works only at the end of a path; anywhere else it counts as a character. A path without a leading `/` gets one. A path cannot contain an underscore, a vertical bar, or any of `` ` ! @ # $ % ^ & ( ) + = [ ] { } ; ' : " \ < > ? ~ ``. To clear a file whose name has one of these characters, clear its whole folder with `*`, such as `/images/*`. ## Clear the files 1. In MyAccount, under **Network**, click **CDN**. On **Manage CDN Services**, click the distribution. 2. Open the **Invalidations** tab, and click **Flush Cache**. **Create New Invalidation** opens, showing the distribution's **Domain** and **Domain Id**. 3. In **Object paths**, enter one or more paths, separated by spaces, commas, or new lines. 4. Click **Flush Cache** in the dialog. **Your Invalidation has been created successfully.** confirms it. A path with a character that is not allowed gets **Please enter the valid object paths**, and nothing is sent; change the path and try again. ## Check that the files are cleared The invalidation is listed on **Invalidations** with **Invalidation ID**, **Invalidations Paths**, **Status**, and **Created On (IST)**. **Status** reads **InProgress** until the edge locations have dropped the files, then **Completed**. Once it reads **Completed**, ask for the file at the Distribution URL: ```bash curl -I https:///images/image1.jpg ``` Replace `` with the distribution's Distribution URL, and the path with your file's. The headers, such as `last-modified` or `content-length`, match the new file at your origin. ## Avoid clearing the cache Query strings do not change what is cached: `/images/logo.png?v=2` gets the same cached file as `/images/logo.png`. To publish a changed file without clearing the cache, give it a new name, such as `/images/logo-v2.png`, and link the new name from your pages. When your origin sends no caching headers, a shorter **Default TTL** also makes changed files show sooner; see [How long files stay cached](/myaccount/cdn/how-to/change-distribution-settings/#how-long-files-stay-cached). Visitors now get the new version of each file you cleared. If they still get the old one, see [Troubleshooting CDN](/myaccount/cdn/troubleshooting/cdn/#visitors-still-get-the-old-version-of-a-file).