Title: database cache question
Last modified: October 26, 2023

---

# database cache question

 *  [Megunticook](https://wordpress.org/support/users/megunticook/)
 * (@megunticook)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/database-cache-question/)
 * Hi,
 * I’m trying to optimize my website for performance and have a question about the
   database cache.
 * On my development site, when I run the W3TC setup guide, it indicates memcached
   as the best choice for database cacheing.
 * Normally I get the same result on my production site. But today I was doing some
   testing and noticed the setup guide is telling me to disable the db cache because
   both memcached and disk options are much slower. See screenshot below (production
   site on top, development site below).
 * What do you make of this? Any idea why suddenly the database cache is so slow
   on the production site but not the dev site? Only difference in setup is that
   the production site has a remote db server while the development site has a local
   database right on the web server. Production is also using a CDN.
 * You think I should just disable db cache on my production site? Seems counter
   intuitive…
 * ![](https://i0.wp.com/cdn.swansislandcompany.com/wp-content/uploads/2023/10/w3tc-
   db-cache.png?ssl=1)
    -  This topic was modified 2 years, 6 months ago by [Megunticook](https://wordpress.org/support/users/megunticook/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/database-cache-question/#post-17155984)
 * Hello [@megunticook](https://wordpress.org/support/users/megunticook/)
 * Thank you for reaching out and I am happy to help!
   This may well be the case 
   with remote DB server. In the initial test, you can see that the time for the
   PROD site is 5.75ms, and the DEV is the full 2 sec
 * Also, the question is if the database is the bottleneck of your website performance,
   and in some cases, Object Cache allows you to get data from the database more
   efficiently. Its purpose is similar to what a Database Cache does. But compared
   to Database Cache, Object cache is more efficient as it allows to processing 
   of fewer requests.
 * To clarify more, it may look counter intuitive, however, this all depends on 
   the website, server, db etc.
 * It does not mean that every setting is good for your website performance.
 * This can also be a temporary hiccup on the server or DB server end, so you may
   want to try and re-do the setup guide and see the results.
 * Thanks!
 *  Thread Starter [Megunticook](https://wordpress.org/support/users/megunticook/)
 * (@megunticook)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/database-cache-question/#post-17157643)
 * Thanks for your feedback on this.
 * I redid the setup guide and got a much different result on the database cache:
 * ![](https://i0.wp.com/cdn.swansislandcompany.com/wp-content/uploads/2023/10/w3tc-
   db-cache-again.png?ssl=1)
 * So I’ve got this set to Memcached now and the guide indicated that “Disk” was
   the best choice for the object cache. Will try this for a while and see how it
   does.
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/database-cache-question/#post-17164295)
 * Hello [@megunticook](https://wordpress.org/support/users/megunticook/)
 * Thank you for your feedback.
   As you can see, the disk is never a good option 
   for DB caching and in your screenshot you can see that the red percentage increases
   the response to almost 5s.
 * As the setup guide suggests the 4.77ms without any caching and 4.44 with Memcached
   is not really a big difference.
   As I’ve mentioned before, you may not need DB
   caching in this case.
 * Thanks!
 *  Thread Starter [Megunticook](https://wordpress.org/support/users/megunticook/)
 * (@megunticook)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/database-cache-question/#post-17167891)
 * Very good, thank you for the helpful information.
 * By the way, I was noticing a page on my dev site was loading slowly and discovered
   an error reported in Chrome’s browser tools involving W3TC. Can you understand
   what’s going awry here? Here’s what Chrome said:
 *     ```wp-block-code
       {
       "key": "811c3e33c30431a379cb279c7043df5a",
       "type": "warning",
       "message": "fopen(/var/www/html/wp-content/cache/object/634/3ce/6343cefe2efb39ac5b5d4187c4158256.php): Failed to open stream: No such file or directory",
       "file": "wp-content/plugins/w3-total-cache/Cache_File.php",
       "line": 453,
       "stack": [
       "fopen()",
       "W3TC\Cache_File->fopen_write()",
       "W3TC\Cache_File->set()",
       "W3TC\ObjectCache_WpObjectCache_Regular->set()",
       "W3TC\ObjectCache_WpObjectCache->set()",
       "wp_cache_set()",
       "get_option()",
       "WP_Optimize_Options->get_option()",
       "Updraft_Smush_Manager->__construct()",
       "Updraft_Smush_Manager::instance()",
       "Updraft_Smush_Manager()",
       "WP_Optimize->get_task_manager()",
       "WP_Optimize_Premium->__construct()",
       "WP_Optimize_Premium::instance()",
       "WP_Optimize_Premium()",
       "WP_Optimize->plugins_loaded()",
       "do_action('plugins_loaded')"
       ],
       "component": "Plugin: w3-total-cache"
       }
       ```
   
 * ![](https://i0.wp.com/cdn.swansislandcompany.com/wp-content/uploads/2023/11/ajax-
   error-chrome-2.png?ssl=1)
 * ![](https://i0.wp.com/cdn.swansislandcompany.com/wp-content/uploads/2023/11/ajax-
   error-chrome.png?ssl=1)
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/database-cache-question/#post-17180955)
 * Hey [@megunticook](https://wordpress.org/support/users/megunticook/)
 * This is just one of the reasons why you should avoid caching objects to disk.
   
   Please switch the caching method and delete the /cache/object/ folder manually
   and let me know if this helps!
 * Thanks!
 *  Thread Starter [Megunticook](https://wordpress.org/support/users/megunticook/)
 * (@megunticook)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/database-cache-question/#post-17201187)
 * Thank you, I set my db caching to memcached.
 * When I test my site in GTMetrix, I’m now getting a new message about slow TTB(
   1.5s). Haven’t seen this before. Any suggestions for how I can pinpoint the cause
   of this? Do I need to reconfigure my W3TC settings? [https://swansislandcompany.com](https://swansislandcompany.com).
   Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘database cache question’ 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/)

## Tags

 * [database cache](https://wordpress.org/support/topic-tag/database-cache/)

 * 6 replies
 * 2 participants
 * Last reply from: [Megunticook](https://wordpress.org/support/users/megunticook/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/database-cache-question/#post-17201187)
 * Status: not resolved