Cloudflare Cache 404 Errors

User
some times cloudflare cache when loading site first in private browser showing wp-super cache files 404 even these files are exists
Assistant
The issue you're experiencing with Cloudflare caching and WP Super Cache files returning 404 errors in a private browser can occur due to a mismatch between Cloudflare's cache settings and your WordPress caching setup. Here's how you can troubleshoot and resolve it:

### **1. Check Cache Rules in Cloudflare**
Ensure that Cloudflare is not overly aggressive in caching dynamic files or cacheable resources.

– **Page Rules:**
– Log in to Cloudflare.
– Go to **Page Rules**.
– Verify that your rules do not cache dynamic content like `/wp-content/cache/` too aggressively.
– If necessary, create a rule to bypass caching for URLs like `*yourdomain.com/wp-content/cache*`.

### **2. Verify File Existence and Permissions**
Ensure that the 404 error isn't caused by file permissions or missing files.

– **File Existence:** Check if the files reported as 404 actually exist on your server (`wp-content/cache` folder).
– **Permissions:** Ensure proper permissions for the `wp-content/cache` directory:
– Directory permissions: `755`
– File permissions: `644`

### **3. Clear Both Caches**
Manually clear both caches to resolve inconsistencies.

– **WP Super Cache:**
– Go to your WordPress admin panel.
– Navigate to **Settings > WP Super Cache > Delete Cache**.
– **Cloudflare Cache:**
– Log in to Cloudflare.
– Go to **Caching > Configuration > Purge Everything** to clear the cache.

### **4. Adjust WP Super Cache Settings**
Review WP Super Cache settings to avoid conflicts with Cloudflare:

– Go to **Settings > WP Super Cache**.
– Ensure the following:
– **Simple Mode** (preferred for Cloudflare setups).
– Enable **Serve cache files to unknown users** to ensure cached files are served to private/incognito browsers.

### **5. Update Cache-Control Headers**
Ensure your cache headers are correctly configured. Cloudflare uses these headers to decide caching behavior.

Add or update rules in your `.htaccess` file to ensure proper `Cache-Control` headers:

<FilesMatch ".html$">
    Header set Cache-Control "max-age=3600, public"
</FilesMatch>
<FilesMatch ".(css|js|jpg|jpeg|png|gif|ico|webp)$">
    Header set Cache-Control "max-age=31536000, public"
</FilesMatch>

### **6. Avoid Cache Conflicts**
Cloudflare's caching can sometimes conflict with WP Super Cache. To reduce conflicts:
– Use the **"Development Mode"** in Cloudflare when making updates.
– Avoid enabling Cloudflare's **"Rocket Loader"** or similar features, as they can interfere with cache files.

### **7. Enable Debugging**
Enable debugging in WP Super Cache to log requests and understand why certain files might return 404.

– Go to **Settings > WP Super Cache > Debug**.
– Enable debugging and monitor the logs for errors related to file paths.

### **8. Use Cloudflare Plugin**
Install the **Cloudflare WordPress plugin** and integrate it with your WordPress site. This plugin can automatically optimize cache settings for WordPress and help prevent such issues.

If the issue persists, you may need to contact your hosting provider to check server-level cache conflicts or Cloudflare support for assistance with caching rules specific to your domain.

User
how to by pass url like *yourdomain.com/wp-content/cache*
Assistant
To bypass caching for URLs like `*yourdomain.com/wp-content/cache*` in Cloudflare, you can set up a page rule. Here’s how to do it:

### **Steps to Create a Page Rule in Cloudflare**

1. **Log In to Cloudflare:**
– Go to the [Cloudflare website](https://www.cloudflare.com) and log in to your account.

2. **Select Your Domain:**
– Click on the domain you want to manage from your Cloudflare dashboard.

3. **Navigate to Page Rules:**
– In the dashboard menu, click on the **"Page Rules"** option.

4. **Create a New Page Rule:**
– Click on the **"Create Page Rule"** button.

5. **Enter the URL Pattern:**
– In the **"If the URL matches"** field, enter the following pattern:

*yourdomain.com/wp-content/cache*

– Replace `yourdomain.com` with your actual domain name.

6. **Select the Settings:**
– From the dropdown menu that appears, select the following setting:
– **Cache Level**: Select **"Bypass"** from the list. This setting will ensure that Cloudflare does not cache requests matching this URL pattern.

7. **Save and Deploy the Page Rule:**
– After selecting the appropriate settings, click on **"Save and Deploy"** to activate the rule.

### **Example:**
If your domain is `example.com`, the URL pattern would be:

*example.com/wp-content/cache*

### **Confirm the Page Rule:**
– After creating the page rule, you should see it listed under the **Page Rules** section. Make sure it is enabled.

### **Testing:**
– After setting up the page rule, clear your Cloudflare cache (under **Caching > Configuration > Purge Everything**) and test the URL again in a private browser window to ensure that the caching is bypassed for the specified URLs.

This setup will help ensure that Cloudflare does not cache any files served from your `wp-content/cache` directory, preventing 404 errors or other issues related to cached files.

User
How to purge everything from cloudflare what is the order
first clear wp super cache
then wpspeedstr
then purge every thing
Assistant
To effectively clear your website's cache when making updates or troubleshooting issues, follow this order:

### **1. Clear WP Super Cache**
– Log in to your WordPress admin panel.
– Navigate to **Settings > WP Super Cache**.
– Click on **Delete Cache** to clear the cache stored by WP Super Cache.

### **2. Clear WP Speedster Cache (if applicable)**
– If you're using the WP Speedster plugin:
– Go to your WordPress admin panel.
– Navigate to **Speedster** (or **WP Speedster**).
– Find the option to **Clear Cache** or **Purge Cache** and click it to clear the cache.

### **3. Purge Everything in Cloudflare**
– Log in to your [Cloudflare account](https://www.cloudflare.com).
– Select the domain you want to manage.
– Navigate to **Caching** in the dashboard menu.
– Under the **Caching** section, click on **Configuration**.
– Click on **Purge Everything**. This action will clear the entire Cloudflare cache for your site.

### **Final Notes:**
– After purging the caches, you may want to test your site in a private/incognito browser window to ensure the changes are reflected and to confirm that the caches have been cleared properly.
– Clearing the caches in this order ensures that any updates you make on your site are properly reflected without any cached versions interfering.

User
there is divi builder cache also
Assistant
If you're using the Divi Builder, it's important to clear its cache as well. Here's the updated order of operations, including clearing the Divi Builder cache:

### **1. Clear WP Super Cache**
– Log in to your WordPress admin panel.
– Navigate to **Settings > WP Super Cache**.
– Click on **Delete Cache** to clear the cache stored by WP Super Cache.

### **2. Clear WP Speedster Cache (if applicable)**
– If you're using the WP Speedster plugin:
– Go to your WordPress admin panel.
– Navigate to **Speedster** (or **WP Speedster**).
– Find the option to **Clear Cache** or **Purge Cache** and click it.

### **3. Clear Divi Builder Cache**
– Log in to your WordPress admin panel.
– Go to **Divi > Theme Options**.
– Navigate to the **Builder** tab, then click on the **Advanced** section.
– Click on the **Clear** button next to **Static CSS File Generation** and **Clear Cache** to remove the Divi Builder cache.

### **4. Purge Everything in Cloudflare**
– Log in to your [Cloudflare account](https://www.cloudflare.com).
– Select the domain you want to manage.
– Navigate to **Caching** in the dashboard menu.
– Under the **Caching** section, click on **Configuration**.
– Click on **Purge Everything**. This action will clear the entire Cloudflare cache for your site.

### **Final Notes:**
– After completing these steps, test your site in a private/incognito browser window to ensure that all changes are reflected and that the caches have been cleared properly.
– This order of operations ensures that you clear all layers of caching, reducing the chances of stale content being served to visitors.

Leave a Comment

Your email address will not be published. Required fields are marked *