Title: Bug when using DONOTCACHEPAGE
Last modified: August 21, 2016

---

# Bug when using DONOTCACHEPAGE

 *  [MattGeri](https://wordpress.org/support/users/mattgeri/)
 * (@mattgeri)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/bug-when-using-donotcachepage/)
 * Hey there,
 * Thanks for the great plugin, by far my favorite caching plugin.
 * I’ve however, discovered a bug. When defining the constant “DONOTCACHEPAGE” and
   setting it to false, i.e. we should cache the page, W3TC ignores the value of
   the constant and assumes you don’t want to cache the page because that constant
   is defined.
 * The error is in PgCache.php in the process method on line 164:
 *     ```
       switch (true) {
                   case defined('DONOTCACHEPAGE'):
                   case defined('DOING_AJAX'):
                   case defined('DOING_CRON'):
                   case defined('APP_REQUEST'):
                   case defined('XMLRPC_REQUEST'):
                   case defined('WP_ADMIN'):
                   case (defined('SHORTINIT') && SHORTINIT):
                       return;
               }
       ```
   
 * That should not just check that it is defined but also check if it is true/false.
 * It’s done correctly on line 515:
 *     ```
       if (defined('DONOTCACHEPAGE') && DONOTCACHEPAGE) {
                   $this->cache_reject_reason = 'DONOTCACHEPAGE constant is defined';
   
                   return false;
               }
       ```
   
 * but because of the code in process.php, it never caches any pages if the constant
   is set to false.
 * Was hoping there was a Github repo so that I could do a fix and send a pull request,
   but I suppose this forum is the next best thing 🙂
 * Thanks,
    Matt
 * [http://wordpress.org/plugins/w3-total-cache/](http://wordpress.org/plugins/w3-total-cache/)

The topic ‘Bug when using DONOTCACHEPAGE’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [MattGeri](https://wordpress.org/support/users/mattgeri/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/bug-when-using-donotcachepage/)
 * Status: not resolved