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 or Please use the bnconfig tool to accomplish this.

W3 Total Cache Troubleshooting


Follow these steps to install the W3 Total Cache plugin:

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.


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.

WP Super Cache


Follow these steps:

  • Download the plugin from

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

      $ sudo chmod 660 /bitnami/wordpress/wp-config.php
  • Upload this directory to your plugins directory. It will create a wp-super-cache directory inside the WordPress plugins directory.

  • If you are using WordPress MU or WordPress Multisite, activate it “network wide”. If you see errors regarding the permissions, they can be ignored.


Follow these steps to enable mod_rewrite Caching:

  • Browse to “Settings -> WP Super Cache” and enable caching.

  • Modify the file at /opt/bitnami/apache/conf/vhosts/htaccess/wordpress-htaccess.conf with the content that the application displays when you click the “Update Mod_rewrite rules” link. Update your wordpress-htaccess.conf file so it looks like this:

      <Directory "/opt/bitnami/wordpress">
      # BEGIN WPSuperCache
      # NOTE: You should include here the content displayed when clicking the "Update Mod_rewrite rules" button
      <IfModule mod_rewrite.c>
        RewriteEngine On
      # END WPSuperCache
  • Also add these lines to the bottom of the file:

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


Follow these steps to enable rewrite Caching:

  • Browse to “Settings -> WP Super Cache” and enable caching.

  • Connect to your instance over SSH and edit the /opt/bitnami/nginx/conf/server_blocks/wordpress-server-block.conf file. Find the block below:

      if ($request_uri !~ "^/phpmyadmin.*$")
        set $test  A;

    Insert the following lines directly above the previous block:

      # WP Super Cache rules.
      # Designed to be included from a 'wordpress-ms-...' configuration file.
      set $cache_uri $request_uri;
      # POST requests and urls with a query string should always go to PHP
      if ($request_method = POST) {
              set $cache_uri 'null cache';
      if ($query_string != "") {
              set $cache_uri 'null cache';
      # Don't cache uris containing the following segments
      if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
              set $cache_uri 'null cache';
      # Don't use the cache for logged in users or recent commenters
      if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
              set $cache_uri 'null cache';
      # Mobile browsers section to server them non-cached version. COMMENTED by default as most modern wordpress themes including twenty-eleven are responsive. Uncomment config lines in this section if you want to use a plugin like WP-Touch
      # if ($http_x_wap_profile) {
      #        set $cache_uri 'null cache';
      #if ($http_profile) {
      #        set $cache_uri 'null cache';
      #if ($http_user_agent ~* (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800)) {
       #       set $cache_uri 'null cache';
      #if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) {
        #      set $cache_uri 'null cache';
      # Use cached or actual file if they exists, otherwise pass request to WordPress
      location / {
              try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args ;

    The rules above are from the WordPress documentation but are not officially supported.

  • Edit the /opt/bitnami/nginx/conf/server_blocks/wordpress-https-server-block.conf file and make the same changes to it.

  • Restart NGINX.



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 wp-cache-config.php and advanced-cache.php files with the following command:

sudo rm /bitnami/wordpress/wp-content/wp-cache-config.php /bitnami/wordpress/wp-content/advanced-cache.php

These files 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 /bitnami/wordpress/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 /bitnami/wordpress/wp-config.php

Quick Cache

Follow these steps:


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 /bitnami/wordpress/wp-content/cache
$ sudo find /bitnami/wordpress/wp-content/cache -type f -exec chmod 664 {} \;
$ sudo find /bitnami/wordpress/wp-content/cache -type d -exec chmod 775 {} \;
$ sudo chown bitnami:daemon /bitnami/wordpress/wp-config.php
$ sudo chmod g+w /bitnami/wordpress/wp-config.php


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: Autoptimize, WP Super Minify or WP Fastest Cache. 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.

Last modification February 9, 2023