{"id":18768,"date":"2020-02-26T12:03:04","date_gmt":"2020-02-26T17:03:04","guid":{"rendered":"https:\/\/www.boldgrid.com\/support\/?p=18768"},"modified":"2024-02-22T10:03:00","modified_gmt":"2024-02-22T15:03:00","slug":"choosing-a-database-caching-method-in-w3-total-cache","status":"publish","type":"post","link":"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/choosing-a-database-caching-method-in-w3-total-cache\/","title":{"rendered":"Choosing a Database Caching Method in W3 Total Cache"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"utf-8\" ?><html><body><p>While <b>Object Caching<\/b> will store executed PHP which may or may not contain information retrieved from your database, it may not cache the majority of calls to your database. If after enabling <b>Object Caching<\/b> you have many database queries being performed, it&rsquo;s time to cache the database queries themselves.<\/p>\n<p><b>Database Caching<\/b> assists with freeing up MySQL server resources taken by serving repeated queries returning the same data each time, so that it has more power to handle real dynamic data.<\/p>\n<div class=\"boldgrid-section\" style=\"margin-top: 60px;\">\n<div class=\"container w3tc-radius\" style=\"border-width: 0px; background-image: url('https:\/\/www.boldgrid.com\/wp-content\/uploads\/2023\/07\/upsell-darker-alt.png'); background-size: cover; background-position: 50% 5%;\" data-image-url=\"https:\/\/www.boldgrid.com\/wp-content\/uploads\/2023\/07\/upsell-darker-alt.png\">\n<div class=\"row upsell-column\" style=\"padding-top: 2em; padding-bottom: 2em; color: #ffffff;\">\n<div class=\"col-lg-1 col-md-1 col-sm-12 col-xs-12 hidden-sm\">&nbsp;<\/div>\n<div class=\"col-lg-5 col-md-6 col-xs-12 col-sm-7\">\n<p class=\"\" style=\"color: #ffffff; line-height: 40px; margin-top: 0;\">Cache your database and get better performance with <strong>W3 Total Cache Pro<\/strong><\/p>\n<\/div>\n<div class=\"col-lg-6 col-md-5 col-sm-5 col-xs-12 text-center align-column-center\">\n<p class=\"\" style=\"border-width: 0px;\"><a class=\"button-w3tc-white\" style=\"border: 2px solid #30BEC4; font-size: 18px; padding: 15px 30px;\" href=\"https:\/\/www.boldgrid.com\/w3-total-cache\/#pricing\">View Plans<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h2 id=\"choosing-a-method\">Choosing a Method<\/h2>\n<p>For suggestions tailored to your hosting plan and recommendations on which <b>Database Caching<\/b> method to use, consider <b>upgrading to W3 Total Cache Pro<\/b> for access to the <b>Statistics<\/b> page.<\/p>\n<h3 id=\"shared-server\">Shared Server<\/h3>\n<p><a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/configuring-w3-total-cache-for-wordpress-with-shared-hosting\/\">In shared hosting platforms, you may only be able to cache files to a disk<\/a>. In such cases, there is only one option available for <b>Database Caching<\/b> unless your hosting provider has a method listed under VPS \/ Dedicated Server or Multiple Servers available.<\/p>\n<h4 id=\"disk\">Disk<\/h4>\n<p>Disk-based caching should only be used when your site requires many expensive database queries, or your MySQL server is extremely slow. Using disk-based <b>Database Caching<\/b> is generally not recommended as it is usually slower than relying solely on MySQL to process queries as they are requested.<\/p>\n<h3 id=\"vps--dedicated-server\">VPS \/ Dedicated Server<\/h3>\n<p>On <a href=\"\/wordpress-vps-hosting\/\">WordPress VPS hosting<\/a> and\/or Dedicated hosting platforms you may use an in-memory caching solution rather than exclusively caching to disk. In-memory caching takes advantage of the much faster read\/write speeds and lower latency of accessing data from system memory compared to disk-based alternatives.<\/p>\n<h4 id=\"alternative-php-cache-apc--apcu\">Alternative PHP Cache (APC \/ APCu)<\/h4>\n<p><b>APC<\/b> refers to <b>Alternative PHP Cache<\/b> which provides in-memory Opcode caching and a key-value store for looking up cached items. This is largely deprecated in favor of modern Opcode Caching mechanisms, as <b>APC<\/b> is not supported in the PHP 7.x branch.<\/p>\n<p><b>APCu<\/b> is similar to <b>APC<\/b>, though in order to support modern variants of PHP it is stripped of Opcode Caching and only provides the in-memory key-value store mechanisms. When paired with modern Opcode Caching mechanisms it can provide the functionality originally provided by <b>APC<\/b>, though it should only be used when you require having a limited cache size.<\/p>\n<p>APC\/APCu is not stable when a lot of memory allocated. In cases where you are caching a small amount of data, <b>APC\/APCu<\/b> may be the ideal method for single-instance hosting platforms such as VPS or Dedicated hosting.<\/p>\n<h4 id=\"eaccelerator\">eAccelerator<\/h4>\n<p><b>eAccelerator<\/b> is an in-memory Opcode caching solution that supports the PHP 4.x and 5.x major versions. This is largely deprecated in favor of modern Opcode Caching mechanisms, as <b>eAccelerator<\/b> is not supported in the PHP 7.x branch.<\/p>\n<h4 id=\"xcache\">XCache<\/h4>\n<p>XCache is an in-memory Opcode caching solution that supports up to the PHP 5.6 release. This is largely deprecated in favor of modern Opcode Caching mechanisms, as <b>XCache<\/b> is not supported in the PHP 7.x branch.<\/p>\n<h4 id=\"wincache-recommended-for-windows-based-environments\">WinCache (Recommended for Windows-based Environments)<\/h4>\n<p><b>WinCache<\/b> is an extension for <a href=\"https:\/\/www.iis.net\">Microsoft IIS<\/a> which provides in-memory Opcode caching and currently supports up to IIS 10 as of 04\/30\/2019. Check the official Microsoft product page for the latest information.<\/p>\n<h3 id=\"multiple-servers\">Multiple Servers<\/h3>\n<p>If you have multiple hosting plans where one plan has root-level access, or if your hosting provider offers addons or bundles providing one of the following solutions, you may offload your in-memory caching to another server. This allows you to separate your actual site and caching solution between multiple servers to compliment each other, and allows for easier scaling to serve many users.<\/p>\n<h4 id=\"memcached\">Memcached<\/h4>\n<p><b>Memcached<\/b> is a high-performance, distributed memory object caching system meant to speed up dynamic web applications by alleviating database load. It provides an in-memory key-value store for small chunks of arbitrary data (strings, objects) from the results of database calls, API calls, or page rendering.<\/p>\n<p><b>Memcached<\/b> is ideal for relatively small and static data, and as a result may be more efficient than Redis<b>. <\/b>It is also multithreaded, which may be a benefit when using a VPS or Dedicated Server with a large resource pool.<\/p>\n<h4 id=\"redis\">Redis<\/h4>\n<p><b>Redis<\/b> is an in-memory data structure store which may be used as a database, cache, and message broker. <b>Redis<\/b> is somewhat of an industry-standard at the time of writing, and can be defined simply as a superset of <b>Memcached<\/b> when purely talking about similarities between each feature set.<\/p>\n<h2 id=\"frequently-asked-questions\">Frequently Asked Questions<\/h2>\n<h3 id=\"enabling-database-caching-didnt-improve-my-performance\">Enabling database caching didn&rsquo;t improve my performance<\/h3>\n<p>First, examine your heaviest SQL queries and ensure those are being cached. Another issue can be that too much data is being transferred too frequently. You may want to check for the following:<\/p>\n<ul>\n<li>Check if there are too many items in the wp_options table that contain autoload=&rsquo;yes&rsquo;<\/li>\n<li>Ensure your cache hit rate is appropriate. If it appears to be too low:\n<ul>\n<li>This may indicate that the cache is being flushed. You may need to determine if a query is causing the cache to be flushed early.<\/li>\n<li>Queries that are causing issues can be moved to a separate group so that they are not affected by the cache being flushed.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 id=\"can-i-use-a-mysql-cluster\">Can I use a MySQL Cluster?<\/h3>\n<p>With W3TC PRO you may use cluster of MySQL servers when a single MySQL instance can&rsquo;t handle all your traffic.<\/p>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>While Object Caching will store executed PHP which may or may not contain information retrieved from your database, it may not cache the majority of calls to your database. If after enabling Object Caching you have many database queries being performed, it&rsquo;s time to cache the database queries themselves. Database Caching assists with freeing up [&hellip;]<\/p>\n","protected":false},"author":529,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"bgseo_title":"","bgseo_description":"","bgseo_robots_index":"index","bgseo_robots_follow":"follow","footnotes":""},"categories":[743,692],"tags":[],"class_list":["post-18768","post","type-post","status-publish","format-standard","hentry","category-database-cache","category-w3-total-cache"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/18768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/users\/529"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/comments?post=18768"}],"version-history":[{"count":8,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/18768\/revisions"}],"predecessor-version":[{"id":125527,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/18768\/revisions\/125527"}],"wp:attachment":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/media?parent=18768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/categories?post=18768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/tags?post=18768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}