Title: 404 Errors
Last modified: February 3, 2018

---

# 404 Errors

 *  Resolved Anonymous User 14978628
 * (@anonymized-14978628)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/)
 * Hey Frank,
 * I’ve been getting a few 404 errors recently for AO css and js files. These are
   AO files in the wp-content cache directory.
 * Not sure why this is happening or what to do about it?

Viewing 15 replies - 1 through 15 (of 35 total)

1 [2](https://wordpress.org/support/topic/404-errors-86/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/404-errors-86/page/3/?output_format=md) 
[→](https://wordpress.org/support/topic/404-errors-86/page/2/?output_format=md)

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9934274)
 * > Not sure why this is happening
 * generally it happens when you clear AO’s cache but there are pages cached elsewhere(
   page cache plugin, page cache at hoster, page cache at sucuri or cloudflare or…,
   page cache in browser) which has pages that still refer to the old cached files.
 * > what to do about it?
 * avoid clearing AO’s cache too often and if you do make sure to also clear any
   page cache you have access to.
 * hope this helps,
    frank
 *  Thread Starter Anonymous User 14978628
 * (@anonymized-14978628)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9934309)
 * Those were my first thoughts/actions. I was using the plugin “Redirection” to
   monitor for 404s which alerted me to this, and has also allowed me to test it
   by spidering my site and seeing if the 404s reappear in Redirection.
 * Clearing my page cache/AO cache didn’t seem to fix the issue.
 * I just tried removing a preload and prefetch which i had in the header for an
   AO css and the issue seems to have been resolved. Strangely, the css i was preloading
   wasn’t the one that was being flagged as causing the 404.
 * I will mark this as resolved for now and update if i notice any more AO 404s 
   being caused by Googlebot.
 * Thanks
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9934336)
 * > AO 404s being caused by Googlebot.
 * aahhhh, Googlebot errors! so this is different; based on previous similar reports
   and investigations it seems like Google is making requests for CSS/ JS from pages
   in its own extensive cache. as you can’t purge Google’s cache, there’s nothing
   much you can do (except not purging AO’s cache). a workaround some people implemented
   is a change in .htaccess to ensure that requests for non-existant autoptimized
   files are answered with a HTTP 410 response header (“gone”) instead.
 *  Thread Starter Anonymous User 14978628
 * (@anonymized-14978628)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9934353)
 * Oh, that would explain it then. Do you have the .htaccess code to return the 
   410 header?
 *  Thread Starter Anonymous User 14978628
 * (@anonymized-14978628)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9934490)
 * Figured it out. I didn’t realize you were referring to a generic htaccess code.
   I thought it was something specific to AO.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9934603)
 * great job @martychc23, have a nice weekend! 🙂
 *  Thread Starter Anonymous User 14978628
 * (@anonymized-14978628)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9934634)
 * Thanks Frank, sorry to have bothered you with this! Have a nice weekend also 
   😉
 *  [samuelmarkno](https://wordpress.org/support/users/samuelmarkno/)
 * (@samuelmarkno)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9937290)
 * Hi, @martychc23 I also have the same Googlebot problem, you solved the error 
   by editing your wp-content / cache / autoptimize / .htaccess or creating another.
   htaccess file for the redirect, could you tell me which code you implemented 
   or an information link, please …
 *  Thread Starter Anonymous User 14978628
 * (@anonymized-14978628)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9937310)
 * Hi, I found a really good solution to this. Basically, when Googlebot encounters
   a file that isn’t there anymore it receives a 404 response. I found out this 
   doesn’t actually mean the file is gone for certain, and so Googlebot will continue
   trying for that file over time.
 * The best way to deal with files/pages you remove is to return a 410 response,
   which means that it’s gone for good and so stop trying to access it.
 * There’s an easy way to deal with this by adding the following to your 404.php
   file:
 * `header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");`
 * If you don’t have a 404.php you can create one by making a .php file containing
   the following:
 *     ```
       <!DOCTYPE html>
       <?php  
       header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");
       header("Cache-Control: max-age=2592000");
       ?>
       <div id="main-content">
       <div class="container">
       <div id="content-area" class="clearfix">     
       <h1><?php esc_html_e('Page Not Found'); ?></h1>
       </div>
       </div>
       </div>
       ```
   
 * That creates a very basic 404 page that returns a 410 response. I kept it basic
   so it doesn’t use much server resources to load.
 * You can then test this by accessing a url that doesn’t exist on your site, and
   then looking at the network tab with Chrome developer tools. You will see the
   410 response.
 * Got this info from here (see last response)
 * [https://stackoverflow.com/questions/41997261/wordpress-change-all-404-to-410-error-code](https://stackoverflow.com/questions/41997261/wordpress-change-all-404-to-410-error-code)
 * Hope this helps you and anyone else with Autoptimize causing 404 errors!
 *  [samuelmarkno](https://wordpress.org/support/users/samuelmarkno/)
 * (@samuelmarkno)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9937338)
 * Thank you, for answering and explaining the solution, greetings.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9937616)
 * nice solution @martychc23, if your theme already has a 404.php you could add 
   this code in there, executing conditionally if this is for an autoptimize_*.css
   or .js file (keeping normal 404 in place for other requests). good job! 🙂
 *  Thread Starter Anonymous User 14978628
 * (@anonymized-14978628)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9961010)
 * Hey Frank, Just so I can avoid such issues in future. Could you please clarify
   when I should clear the Autoptimize cache? For example, i’ve added some css to
   my style.css. Should i now clear the cache? Thanks
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9961528)
 * > For example, i’ve added some css to my style.css. Should i now clear the cache?
 * No, AO will “see” the new CSS and create a new AO’ed CSS-file automatically. 
   I clear my cache a couple of times per year.
 *  Thread Starter Anonymous User 14978628
 * (@anonymized-14978628)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9962174)
 * >  I clear my cache a couple of times per year.
 * Under what circumstances would you clear your cache?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/404-errors-86/#post-9962213)
 * when I’m changing AO options, for testing purposes mainly 🙂

Viewing 15 replies - 1 through 15 (of 35 total)

1 [2](https://wordpress.org/support/topic/404-errors-86/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/404-errors-86/page/3/?output_format=md) 
[→](https://wordpress.org/support/topic/404-errors-86/page/2/?output_format=md)

The topic ‘404 Errors’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 35 replies
 * 4 participants
 * Last reply from: Anonymous User 14978628
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/404-errors-86/page/3/#post-10395033)
 * Status: resolved