Just like caching the front-end static files play an important role in improving the site speed. Similarly, we need to cache the backend for enhancing server performance. Therefore, we will use the Redis Object Cache.
The Redis Object Cache helps in storing the complex MySQL queries on RAM memory. Hence, next time any similar query request, the Object cache will serve the output stored in RAM rather than hitting the fresh MySQL query. Thus, enhancing the overall speed and performance.
Install Redis Server on WordPress server:
apt-get install redis-server php7.3-redis
The output of the command may throw an error like “E: Couldn’t find any package by regex ‘php7.3-redis’” if so please run the below command in docker container were the wordpress server installed.
pecl install -o -f redis \ && rm -rf /tmp/pear \ && docker-php-ext-enable redis
Configure Redis Server :
Edit the redis config file with below values:
/etc/redis/redis.conf add the below lines to set the maximum memory limit the Redis Server should use for processing the Object Cache. #it depends on how much RAM you have. On a 1GB server, I use 100mb. maxmemory 100mb
Then close the configuration file and restart the Redis server.
Setup Redis Object Cache for WordPress
- First of login to the wordpress admin panel and install the plugin Redis Object Cache.
- Then activate the Plugin and navigate to Settings > Redis
- Hit on Enable Object Cache command button
- After enable the redis object cache it will looks like below.
Monitoring Redis Object Cache Using Command Line
Using the following command in the SSH terminal, we can monitor Redis caching from the command line.
redis-cli monitor
The output should be looks like below.
So these are the important steps to set up wordpress on docker with redis to enhance server performance. Expert professionals at IServerSupport provide dedicated and effective server management services for your business requirements.
Thank you!!!!!
Leave A Comment