...
- Setup Cloudflare via this article: Setup CloudFlare
- Setup Redis via this article: Server Optimization#Redis
- Setup your OpCache via this article: Server Optimization#OpCache
Run the following:
Code Block sudo a2enmod expires sudo a2enmod headers sudo a2enmod ext_filter
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
- Install the community version of W3 Total Cache
- Go into your dashboard then Performance.
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
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
- Scroll Down to Cache Preload
- Check Automatically prime the page cache && Preload the post cache upon publish events
- Check Automatically prime the page cache && Preload the post cache upon publish events
- Scroll Down to Cache Preload
- Under Browser Cache, do the following:
- Check everything in General BUT:
- Set W3 Total Cache header
- Prevent caching of objects after settings change
- Do not process 404 errors for static objects with WordPress
- Rewrite URL structure of objects
- Check everything in General BUT:
- Go to Extensions, do the following:
- Deactivate everything but CloudFlare & Yoast (if using Yoast, which you shoud!)
- Click on settings on Cloudflare
- Enter your API key and all your settings from Cloudflare should come over.
- Make sure you have minify setup (which was in the other wiki on Cloudflare)
- Enter your API key and all your settings from Cloudflare should come over.
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>
- Install Scripts to Footer Add the Autoptimize plugin
- Go to Settings → Scripts to FooterCheck Keep jQuery in the Header
Add this to your functions.php
Add the Autoptimize pluginCode 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);
- Go to Settings → AutoptimizeAutoptimize
- Check Optimize JS Code?
- Check Also aggregate inline JS?
- Remove all entries from: Exclude scripts from Autoptimize:
- Check Optimize CSS Code?
- hit the show advanced settings at the top
- Uncheck everything except Inline all CSS?
- Save Changes and Empty Cache
- Go to Settings → Scripts to FooterCheck Keep jQuery in the Header