...
- 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>
- Add the Autoptimize plugin
- Go to Settings → Autoptimize
- 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
- Move google fonts to footer:
- Do a view page source on your site.
- Search for 'https://fonts.googleapis.com and grab the id of the stylesheet
- i.e: <link rel='stylesheet' id='tp-open-sans-css' href='https://fonts.googleapis.com/css ...
Put this in your functions.php (use the id without the -css)
Code Block /** * Remove Google font files from header. */ function remove_google_fonts_header() { wp_dequeue_style( 'tp-open-sans' ); wp_dequeue_style( 'OTHER-GOOGLE-FONT-ID' ); } add_action( 'wp_enqueue_scripts', 'remove_google_fonts_header', 20 ); /** * Add google fonts to footer. */ function add_google_fonts_footer() { wp_enqueue_style( 'tp-open-sans' ); wp_enqueue_style( 'OTHER-GOOGLE-FONT-ID' ); }; add_action( 'get_footer', 'add_google_fonts_footer', 21 );
- Search for 'https://fonts.googleapis.com and grab the id of the stylesheet
- Do a view page source on your site.