azurewordpress

Optimize WordPress

Web application performance problems are not easy to fix properly. The responsiveness of your application at a given moment depends on many factors: the application code, installed plugins, AWS load, server type, caching mechanism, etc.

The most common reason for performance issues is lack of any caching. Turning it on, which for most Bitnami stacks is not that difficult, dramatically improve the server performance.

IMPORTANT: To apply each cache plugin, it is assumed that your WordPress instance is already running at the domain root URL, such as at http://mywp.bitnamiapp.com/ or http://example.com/. Please use the bnconfig tool to accomplish this.

W3 Total Cache

Follow these steps:

Troubleshooting

Installation

During installation, W3 Total Cache may display an error stating that some Apache modules are not detected on the server, when they are in fact installed. This error is a known bug in the W3 Total Cache plugin and may be safely ignored.

Debugging

If you have problems configuring W3 Total Cache, try to enable “Debug mode”. Browse to the W3 Total Cache admin and select at least the “Page Cache” option in the “Debug” section. Then, browse to one of your Web pages and check the source code. There should be debugging information at the end, which you can use to check if caching works properly.

If WordPress is installed at the /wordpress path, there may be a conflict between the permalink rewrites and the ones added by the W3 Total Cache plugin. To resolve this, ensure that all the Rewrite entries are removed or commented out in the /opt/bitnami/apps/wordpress/conf/httpd-app.conf file.

WP Super Cache

Follow these steps:

  • Download the plugin from https://wordpress.org/plugins/wp-super-cache/.
  • Upload this directory to your plugins directory. It will create a /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/wp-super-cache/ directory.
  • If you are using WordPress MU or WordPress Multisite, activate it “network wide”.
  • Browse to “Settings -> WP Super Cache” and enable caching.

Using mod_rewrite Caching

To enable this option, modify the file at /opt/bitnami/apps/wordpress/conf/htaccess.conf with the content that the application displays when you click the “Update Mod_rewrite rules” link. Update your htaccess.conf file so it looks like this:

<Directory "/opt/bitnami/apps/wordpress/conf/">
# BEGIN WPSuperCache
<IfModule mod_rewrite.c>
RewriteEngine On
...
# END WPSuperCache
</Directory>

Also add these lines to the bottom of the file:

<Directory "/opt/bitnami/apps/wordpress/htdocs/wp-content/cache">
    # BEGIN supercache
    <IfModule mod_mime.c>
        <FilesMatch "\.html\.gz$">
            ForceType text/html
            FileETag None
        </FilesMatch>
        AddEncoding gzip .gz
        AddType text/html .gz
    </IfModule>
    <IfModule mod_deflate.c>
        SetEnvIfNoCase Request_URI \.gz$ no-gzip
    </IfModule>
    <IfModule mod_headers.c>
        Header set Cache-Control 'max-age=3, must-revalidate'
    </IfModule>
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType text/html A3
    </IfModule> `` # END supercache
</Directory>

Troubleshooting

Debugging

If you have problems configuring WP Super Cache, try to enable “Debug mode”. Browse to the WP Super Cache settings, click on “Debug” and enable the “debugging” option. Once you have saved the changes, you will find the current log file at the top of the web page.

Prior installation

If you have WP-Cache installed already, please disable it. Edit wp-config.php and make sure that the WP_CACHE and WPCACHEHOME defines are deleted. Remove the files /opt/bitnami/apps/wordpress/htdocs/wp-content/wp-cache-config.php and /opt/bitnami/apps/wordpress/htdocs/wp-content/advanced-cache.php. These will be recreated when you install this plugin.

Errors about missing configuration files

Connect to your instance over SSH and make the wp-config.php file writable by running the command below:

$ sudo chmod 660 /opt/bitnami/apps/wordpress/htdocs/wp-config.php

Reactivate the WP Super Cache plugin (if necessary) and confirm that the error messages no longer appear. Once you have confirmed that the WP Super Cache plugin is working, run the command below to reset the original permissions for the wp-config.php file for security reasons:

$ sudo chmod 640 /opt/bitnami/apps/wordpress/htdocs/wp-config.php

Quick Cache

Follow these steps:

Troubleshooting

Permission issues

You might see the following errors:

Permissions: Please check permissions on /wp-content/cache . Quick Cache needs write-access to this directory. Permissions need to be 755 or higher.
Permissions: Please check permissions on /wp-config.php . Quick Cache needs write-access to this file. Permissions need to be 755 or higher.

This arises because the default ownership of the application files is usually set to the bitnami user and daemon group, so users can edit the files directly as the bitnami user and the Web server is also able to read them. In this case, when the Web server needs to be able to modify any files or directories, it becomes necessary give write permissions to the group too.

Execute the commands below:

$ sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-content/cache
$ sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content/cache -type f -exec chmod 664 {} \;
$ sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content/cache -type d -exec chmod 775 {} \;
$ sudo chown bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-config.php
$ sudo chmod g+w /opt/bitnami/apps/wordpress/htdocs/wp-config.php

Minify

This plugin uses the Minify engine to combine and compress JS and CSS files to improve page load time. There are several plugins for the same purpose: Minify, WP Minify or Better WordPress Minify. You can install one of them and it should improve your page load time. In all cases it is necessary to have WordPress running in the root URL.