Optimizing BitNami for PageSpeed Insights and GTmetrix

PageSpeed Insights

Warning to our readers: non-baby techy stuff here, and for those finding me from the internet: Warning this is a baby tech site that just happens to be talking about a server.

Also warning to people looking for tech support – this document was created October 2013, it’s potentially outdated by the time you get it. Most of the stuff I was looking for when optimizing this was from years ago and simply did not work.

So, it may or may have not been mentioned that I work some of my WordPress magics with BitNami in a VMWare environment. After months of playing with their optimized setup and finding incorrect instructions at every level of their wiki on how to optimize BitNami, I decided to figure it out and correct the issues.

With fixing things, the change in Page Speed Insights and GTMetrix went way up and so did theITbaby’s incoming traffic. I saw a 25% increase the first week, and by three weeks in I was getting in the neighborhood of 41% more traffic. I sent @Bitnami a note and they said they would fix the wiki. But as of the moment there’s even less information there than there was before.

Whether they’re not interested in giving the information so you pay for support, or just don’t consider giving the right information a priority, no idea. You get what you pay for and you didn’t pay for this.

So, without further adieu a quick and dirty optimizing BitNami piece:

Optimizing BitNami

BitNami .htaccess doesn’t work

WordPress plugins, such as W3 Total Cache will fail saying you need to manually add some lines to /.htaccess. You add these lines and nothing happens. You could add any lines you want there and it really doesn’t matter as .htaccess is not ever touched.

As a security measure, BitNami ignores .htaccess by default and uses /opt/bitnami/apps/wordpress/conf/htaccess.conf.

htaccess.conf is a roll-up of all directories’ .htaccess files, and for a default BitNami install, you can make any changes you want  within a directory tag.

leverage browser caching on BitNami

On a default install of BitNami, editing /opt/bitnami/apps/wordpress/conf/htaccess.conf, add the following:

<Directory “/opt/bitnami/apps/wordpress/htdocs”>
## EXPIRES CACHING ##

ExpiresActive On
ExpiresByType image/jpg “access plus 9 months”
ExpiresByType image/jpeg “access plus 9 months”
ExpiresByType image/gif “access plus 9 months”
ExpiresByType image/png “access plus 9 months”
ExpiresByType text/css A2592000
ExpiresByType text/html “access plus 9 months”
ExpiresByType application/pdf “access plus 9 months”

ExpiresByType text/x-javascript “access 1 month”

ExpiresByType application/x-shockwave-flash “access plus 9 months”
ExpiresByType image/x-icon “access plus 9 months”
ExpiresDefault “access plus 3 months”

## EXPIRES CACHING ##

</Directory>

It should be noted that you can probably have all those in the same format, but I was goofing around with anything I could to make it work when I thought it was in the .htaccess file.

Keep in mind I’m not an Apache expert, but my bet is you get one <directory> tag per .htaccess directory, so probably everything you’re going to need to do will go in there.

You’ll need to uncomment the line

LoadModule expires_module modules/mod_expires.so

in your httpd.conf

Enable compression in BitNami

Compression for some reason is turned off by default in BitNami. You need to edit your httpd.conf file located at /opt/bitnami/apache2/conf and remove the # in front of LoadModule deflate_module modules/mod_defate.so. You’ll also want to add some stuff near the end to enable it to compress whatever you want.

For me, I put the following at the end of the file and it’s worked fine:

#by pk
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Add W3 Total Cache to BitNami

So, W3 Total Cache won’t work in a default install of BitNami, it will tell you to edit /.htaccess, as we’ve discussed Bitnami doesn’t use .htaccess, and W3 Total Cache can’t edit it even it it wanted.

Take whatever is suggested by W3 Total Cache and put it in your  /opt/bitnami/apps/wordpress/conf/htaccess.conf between the directory tags you’ve established for your default install.

Presumably <Directory “/opt/bitnami/apps/wordpress/htdocs”> and </directory> unless you did anything fancy, and if you did you’re beyond me.

Eliminate render-blocking JavaScript and CSS in above-the-fold content

I used the plugins “Asynchronous Javascript” and “Autoptimize”

PageSpeed suggests I Optimize Images

I’m using EWWW Image Optimizer, and that seems to have fixed most of the images. Occasionally I will run across an image that PageSpeed has a beef with still, but sometimes you just realize you’re never going to be perfect.

You can optimize the image again manually if you really care that much using Yahoo’s Smush.it tool.

Reduce server response time

Got nothing on that for you. A virtual server runs slower than a real one. That slowness can sometimes reflect a bit of a lag. The difference between a response time of 26 ms and 56 ms for an initial connection can be thousands of dollars and not make a bit of difference to the end user.

GTmetrix suggestions

GTmetrix

Specify Image Dimensions – got nothing, supposedly that’s done in WP css and certain themes. I have no advice here and hope someone can post something in the comments.

Add Expires headers – again, got nothing – checking that now.

Make fewer HTTP requests – nada.

Use a content delivery network – the Jetpack plugin has one of these. Look up Photon under Jetpack and you can choose this. I stopped using it as I read the images would no longer translate back to here on Google Image Search and you have no idea how many people come in via photos we’ve posted.

Wrap-up

That’s about it. It should go without saying that you should make a complete backup of your install before you make any changes that I’m recommending. Or at least make a backup of the configuration files.

I spent hours attempting to figure this out and my rinky dink site now scores better on GTmetrix and Google’s PageSpeed Insights than the WP install managed by professionals on a dedicated server on another site I write for.

You should also realize that even Google doesn’t score 100 on it’s own PageSpeed Insights. It’s currently 86 for mobile and 98 for desktop. What I managed to do here didn’t top us out, but it went a long way toward eliminating the worst offender issues.