Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Setup Cloudflare via this article: Setup CloudFlare
  2. Setup Redis via this article: Server Optimization#Redis
  3. Setup your OpCache via this article: Server Optimization#OpCache
  4. Run the following:

    Code Block
    sudo a2enmod expires
    sudo a2enmod headers
    sudo a2enmod ext_filter


  5. If you are using GIT on digitalocean, add this to your gitignore:

    Code Block
    # Ignore paths that contain user-generated content.
    /wp-content/ai1wm-backups
    /wp-content/cache
    /wp-content/uploads/
    /wp-content/w3tc-config/
    /wp-content/advanced-cache.php
    /wp-content/db.php
    /wp-content/object-cache.php
    
    #htaccess for w3tc
    .htaccess
    
    


  6. Install the community version of  W3 Total Cache
    1. Go into your dashboard then Performance.
    2. Under General do the following:

      Code Block
      Page Cache – ENABLE
      Minify – DISABLE
      Opcode Cache - set to Zend OpCache
      Database Cache – ENABLE (set to disk)
      Object Cache – ENABLE (set to Redis)
      Browser Cache – ENABLE
      CDN – DISABLE
      Reverse Proxy – DISABLE
      Monitoring – NO ACTION
      Debug – DISABLED


    3. Under Page Cache do the following:

      Code Block
      Cache posts page = CHECKED
      Don't cache front page = NOT CHECKED
      Cache feeds: site, categories, tags, comments = CHECKED
      Cache SSL (https) requests = CHECKED
      Cache URIs with query string variables = NOT CHECKED
      Cache 404 (not found) pages = NOT CHECKED
      Don't cache pages for logged in users = CHECKED
      Don't cache pages for following user roles = NOT CHECKED


      1. Scroll Down to Cache Preload
        1. Check Automatically prime the page cache && Preload the post cache upon publish events

    4. Under Browser Cache, do the following:
      1. Check everything in General BUT
        1. Set W3 Total Cache header
        2. Prevent caching of objects after settings change 
        3. Do not process 404 errors for static objects with WordPress 
        4. Rewrite URL structure of objects

    5. Go to Extensions, do the following:
      1. Deactivate everything but CloudFlare & Yoast (if using Yoast, which you shoud!)
      2. Click on settings on Cloudflare
        1. Enter your API key and all your settings from Cloudflare should come over.  
          1. Make sure you have minify setup (which was in the other wiki on Cloudflare)
  7. On the server, add this to your .htaccess

    Code Block
    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
        Header set Cache-Control "max-age=290304000, public"
    </FilesMatch>
    
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/jpg "access 1 year"
        ExpiresByType image/jpeg "access 1 year"
        ExpiresByType image/gif "access 1 year"
        ExpiresByType image/png "access 1 year"
        ExpiresByType text/css "access 1 month"
        ExpiresByType text/html "access 1 month"
        ExpiresByType application/pdf "access 1 month"
        ExpiresByType text/x-javascript "access 1 month"
        ExpiresByType application/x-shockwave-flash "access 1 month"
        ExpiresByType image/x-icon "access 1 year"
        ExpiresDefault "access 1 month"
    </IfModule>
    
    
    


  8. Install Scripts to Footer plugin
    1. Go to Settings → Scripts to Footer
      1. Check Keep jQuery in the Header

  9. Add this to your functions.php

    Code Block
    /**
     * Adds async tag to JQuery
     */
    function add_async_attribute($tag, $handle) {
      // add script handles to the array below
      $scripts_to_defer = array('jquery-core','jquery-migrate');
    
      foreach($scripts_to_defer as $defer_script) {
        if ($handle == $defer_script) {
          return str_replace(' src', ' async src', $tag);
        }
      }
      return $tag;
    }
    add_filter('script_loader_tag', 'add_async_attribute', 10, 2);


  10. Add the Autoptimize plugin
    1. Go to Settings → Autoptimize
    2. Check Optimize CSS Code? 
      1. hit the show advanced settings at the top
      2. Uncheck everything except Inline all CSS?
      3. Save Changes and Empty Cache