Optimizing WordPress in a Cloud Environment

As one of the most popular CMS platforms, WordPress can be configured for many uses. With the proper utilization of plugins and infrastructure, optimizing WordPress in a cloud environment can be easy. Below are a few tips to speed up your site and better your overall web score.

minify

Minifying CSS/Javascript

Removing any extra characters within your style sheets or Javascript files minimizes file size, allowing for a faster download. There are many tools online for minifying CSS and Javascript. Alternatively there are many plugins that will automatically do this for you. Async CSS and Javascript is a WordPress plugin that, on top of minifying CSS, can also fix render-blocking Javascript and CSS issues. This will help overall with page speed and your score on Google Pagespeed Insights.

Disable Comments on Pages

Even though your page may not have comment functionality on it, WordPress is still loading the Javascript to handle the function. The Disable Comments plugin allows you to disable the comment-reply.js loading on certain page types. You can define it to only disable the script on pages and continue to allow it on posts; you can even disable it across your entire site. This will shave a good portion of a second off of your site’s load time.

 htaccess

.htaccess For compression and output filters

Compression by default is not utilized in a WordPress installation. You will see a drastic performance increase by adding the following lines of code to your .htaccess file. The following lines compression and also adds some output filters and expires headers that will overall better your sites performance.


#Setting Mod_deflate to enable to compress all file types
SetOutputFilter DEFLATE
#don't compress these
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary


ExpiresActive on
ExpiresByType image/jpeg A604800
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType audio/mpeg A604800
ExpiresByType text/x-javascript A604800
ExpiresByType image/x-icon A604800
ExpiresByType text/css A604800
ExpiresByType font/eot A604800
ExpiresByType font/ttf A604800
ExpiresByType text/javascript A604800
ExpiresByType text/html A90
ExpiresByType text/xml A604800
ExpiresByType application/x-javascript A604800 



speed

Caching

In a load-balanced environment we highly recommend WP-Supercache to enable caching of your WordPress sites. The primary purpose of Supercache is to create a static HTML version of your pages so that you may lower your sites required resources by delivering a single static HTML page vs. a dynamic PHP page. While there are other caching plugins available, in load balanced environments such as Cloud Sites, we’ve found that Supercache provides the best performance.

 jpg

Image Optimization

Often overlooked, images are one of the main contributing factors to a slow site. It is best practice to save your images for web by exporting JPEGs out as progressive JPEGs. If you’re using Photoshop, choose Save for Web and set the image quality to 60%. This will cut the file size down significantly. If an image editing program is not available there is a wonderful plugin called EWWW Image Optimizer. The plugin will scan your media library and identify images that I can compress, and save as progressive JPEGs.

82

Caching to an External Server using Redis

Redis caching will bring a dramatic increase in site speed. Redis will take all the load off of the server/database by serving a single static HTML file to be served from a performance server. What makes this so great is the fact that you can run multiple sites off of a single server. A developer by the name of Benjamin Adams has a great resource on github for setting up Redis caching on WordPress sites specifically. If you have hundreds of customers in need of a caching solution, you can simply place in Benjamin’s index files, alter the credentials to match your Redis Server and load the site. On the initial load of a page, the index file will connect to the Redis server, create a static HTML file, and serve it on future loads. I recommend not setting this up until your site is completed because any changes to the site will require a flushing of the cache on the Redis server. This is a nice alternative to a staging environment because when logged in the WordPress admin panel you will be the only one seeing live changes on the site…those who are not logged in are being served the static HTML files on the Redis server.

For more information, read more here on what Cloud Sites by Rackspace can do for you!