In this article:
- Speed Up Your WordPress Website.
- A Difference of Just 100ms in Page Load Speeds Can Cause a Visitor to Prefer Your Competitor’s Website.
- Choosing a Method
- Shared Server
- VPS / Dedicated Server
- Alternative PHP Cache (APC / APCu)
- WinCache (Recommended for Windows-based Environments)
- Multiple Servers
- Frequently Asked Questions
- Enabling database caching didn’t improve my performance
- Can I use a MySQL Cluster?
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’s time to cache the database queries themselves.
Database Caching 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.
Choosing a Method
For suggestions tailored to your hosting plan and recommendations on which Database Caching method to use, consider upgrading to W3 Total Cache Pro for access to the Statistics page.
In shared hosting platforms, you may only be able to cache files to a disk. In such cases, there is only one option available for Database Caching unless your hosting provider has a method listed under VPS / Dedicated Server or Multiple Servers available.
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 Database Caching is generally not recommended as it is usually slower than relying solely on MySQL to process queries as they are requested.
VPS / Dedicated Server
On WordPress VPS hosting 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.
Alternative PHP Cache (APC / APCu)
APC refers to Alternative PHP Cache 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 APC is not supported in the PHP 7.x branch.
APCu is similar to APC, 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 APC, though it should only be used when you require having a limited cache size.
APC/APCu is not stable when a lot of memory allocated. In cases where you are caching a small amount of data, APC/APCu may be the ideal method for single-instance hosting platforms such as VPS or Dedicated hosting.
eAccelerator 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 eAccelerator is not supported in the PHP 7.x branch.
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 XCache is not supported in the PHP 7.x branch.
WinCache (Recommended for Windows-based Environments)
WinCache is an extension for Microsoft IIS 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.
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.
Memcached 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.
Memcached is ideal for relatively small and static data, and as a result may be more efficient than Redis. It is also multithreaded, which may be a benefit when using a VPS or Dedicated Server with a large resource pool.
Redis is an in-memory data structure store which may be used as a database, cache, and message broker. Redis is somewhat of an industry-standard at the time of writing, and can be defined simply as a superset of Memcached when purely talking about similarities between each feature set.
Frequently Asked Questions
Enabling database caching didn’t improve my performance
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:
- Check if there are too many items in the wp_options table that contain autoload=’yes’
- Ensure your cache hit rate is appropriate. If it appears to be too low:
- 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.
- Queries that are causing issues can be moved to a separate group so that they are not affected by the cache being flushed.
Can I use a MySQL Cluster?
With W3TC PRO you may use cluster of MySQL servers when a single MySQL instance can’t handle all your traffic.
W3 Total Cache
You haven't seen fast until you've tried PRO
Full Site CDN + Additional Caching Options
Advanced Caching Statistics, Purge Logs and More
Everything you need to scale your WordPress Website and improve your PageSpeed.