Client Area

 Client Area

Improve WordPress loading speed with Redis on Plesk Onyx

Sections

    Redis-server is a powerful keys storage solution, and with the WordPress plugin Redis-object-cache, we can improve WordPress loading speed and use Redis-server as persistent object-cache backend. But at first, we have to install redis-server.

    You have the choice between installing Redis directly on your Plesk server, or running Redis inside a docker container.

    Local installation

    On debian 8 Jessie, you can install redis-server easily with the package available on the dotdeb.org repository.
    You can use my script to install redis-server on debian 8 :

    bash <(wget --no-check-certificate -O - https://git.virtubox.net/virtubox/plesk-script/raw/master/redis-cache.sh)

    Or install redis manually, by adding the main repository to your sources.list

    echo 'deb http://packages.dotdeb.org jessie all' > /etc/apt/sources.list.d/dotdeb.list
    wget https://www.dotdeb.org/dotdeb.gpg
    apt-key add dotdeb.gpg &>/dev/null

    And install redis-server :

    apt-get update && apt-get upgrade -y &>/dev/null
    apt-get install redis-server -y &>/dev/null

    Then start the redis-server service :

    service redis-server start

    Running Redis with a docker container

    You can create your container from the Plesk docker manager :
    I have used the bitnami/redis image, and the following settings :

    bitnami redis container docker plesk onyx

    You can also create your container directly from the command line :

    docker run \
        -e REDIS_PASSWORD=redispassword \
        -v /var/redis:/bitnami \
        -p 6379:6379 \
        bitnami/redis:latest

    Install Redis-object-cache in WordPress

    Our redis-server is now running properly, so you can install the plugin redis-object-cache using the wordpress plugin manager.
    Before enabling object-cache, you have to add following line in your wp-config.php file :

    define( 'WP_CACHE_KEY_SALT', 'yoursitename:' );

    It will add a prefix to all cache keys stored in redis, and allow you to use object-cache for multiple wordpress instances on the same server.
    If you have set a password to secure redis, you will also have to add the following line in your wp-config.php file :

    define( 'WP_REDIS_PASSWORD', 'redispassword' );

    Then, you can enable object-cache in the plugin settings page :

    redis object cache wordpress

    in Plesk