You want your website's content to load quickly. If it doesn't, you risk losing customers. A common method for getting websites to load quickly is to cache previously requested Web pages. In this article, we discuss Redis often used for this purpose.
Improving the performance of modern Web sites includes implementing caching as an essential step. In particular, caching dynamic content is beneficial. Dynamic content requires building the page by retrieving or calculating various data. By caching those results in particular, you gain significant time savings. Although Web server software such as Apache or NGINX also has functionality for caching Web content, software solutions such as Redis are better suited. This is because they are specifically designed for this task and do not have to deal with managing the Web pages themselves.
What are the capabilities of Redis? #
First of all, Redis is a so-called in-memory database. Thus, all content resides in fast RAM memory, allowing Redis to deliver data quickly. Redis can also store data persistently by keeping a journal. However, this should be seen as a way to have the vast majority of the data available quickly, without worrying about losing a little bit.
Furthermore, Redis uses a simple structure to store data. All data is simply stored as key-value pairs. Thus, Redis is not a database like Oracle, MariaDB or PostgreSQL, which organizes data into columns and rows. Although the associated query language for retrieving data (SQL) is flexible, it also carries a lot of overhead. Redis, on the other hand, falls under the NoSQL databases and delivers data quickly due to its simple storage structure.
Enabling Redis in DirectAdmin #
- Click Redis under the "Advanced Features" in DirectAdmin.
- Enable Redis.
- The value at "Path to redis socket file" you should use later when installing Redis in your Content Management System (WordPress, Drupal, ...)
Linking Redis with WordPress #
- Log in to your WordPress website and install the "Redis Object Cache" plug-in.
- You need to edit the wp-settings.php file.
- Place the code below in the file. You need to modify '/home//.redis/redis.sock' to the value you can find in DirectAdmin (Step 3 of previous roadmap).
define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/home//.redis/redis.sock' );