Category: Used Boats Ahoy!

URL Rewriting (Part 2)

I’ve written some very basic URL rewriting scripts in the past.  With only a few URL parameters this is pretty simple to accomplish with a few lines of code.

For example, I had written a basic CMS where URLs followed a specific pattern using .htaccess scripting.  The rewrite engine would be able to convert this into something Apache can read.

  • The URL bar would read as follows:
    • http://www.domain.com/category-x/article-y
  • The web server would read this as:
    • http://www.domain.com?category=category-x&article=article-y

This is fine enough for basic URL patterns, but what happens when the URL tree is a little more complicated?  Starting in Joomla! version 1.5, they included a build in router that can be created on a component level.

Used Boats Ahoy! was created before this was available, so I continued to use the module JoomSEF from part one of this article.  Fortunately the scripting required for JoomSEF to work properly with a component followed a number of the rules the built in 1.5 router uses.  Unfortunately, JoomSEF only required instructions to generate the URLs and not to be able to return the URL to a form the web server understands, which is much more difficult.   Also, moving away from the original method meant a number of the URLs would no longer be valid which requires an extra layer of error handling.

URL Rewriting (Part 1)

URL rewriting is a process I’ve been using on a number of websites for a long time.  Modern CMS solutions have various built in functions and plugins to make this simple for anything that you might download and try out of the box.  What is under the hood is much less straight forward.

In older versions of Joomla!, my go-to was a plugin called joomSEF.  If all of the links are formatted correctly, this plugin will convert standard php links into more user-friendly style links.  What is happening under the hood?  Well first when the page loads, all of the links that are formatted in a way that Joomla! understands are read, then matched against the database for all of the user-friendly URLs that have been generated.  If the matches are found, the user-friendly URLs will be displayed on the page.  If the match is not found, then the plugin will generate it then insert the record into the database.

mod_sef

While this process is fine for websites with small to medium number of links, any kind of text matching in the database is a very resource intensive process.  One of my websites eventually had to be moved to a VPS server because of this.  By the time it was deactivated, this website alone had 1,872,945 records to search through in a table reaching upwards of a gigabyte.  I needed to actively prune unused records every so often by looking to see which URLs have been unused.

 

mod_sef2

 

Making it Rain in Cachemere

In a previous post (Overdue Updates) I mentioned working through some issues to help increase speed.  Of all the minor tweaks I did, I found the root causes of speed issues which were two-fold:

  • Web Service Calls
  • Generating SEO Friendly URLs

Thankfully, there was a way to help alleviate both problems with one solution, Cache.  I built caching functions into this Used Boats Ahoy!, but due to feed changes, they were not working exactly as intended.

  • Original Process (No Cache)
    • Page Request►Web Service Call►Process Feed►Display
  • Original Process (WithCache)
    • Page Request►Read Cache►Web Service Call*►Write Cache*►Process Data►Display Data
  • New Process
    • Page Request►Read Cache►Web Service Call*►Process Data*►Write Cache*►Display Data

* If needed

With this new process, the server will only have to call the Web Service and process the majority of the data only if the cache is out of date, or doesn’t exist yet.  Where many pages were taking 2 seconds to load previously, now take 0.3 seconds if being called from the cache.

Overdue Updates

Over the last few weeks I have been performing some much needed maintenance on the Used Boats Ahoy! website.  I originally had much more ambitious plans for this website, but I decided to start with an interim solution.

Used Boats Ahoy! is built on top of Joomla 1.5, which has become obsolete by a few versions.  I began researching on how to bring it up to version, but unfortunately there are currently too many ties to deprecated APIs to upgrade.  This led me to starting a fresh branch which will eventually replace the current project.  I decided for the time being, updating the current project made the most sense.

Change Summary

  • SEO updates to URL rewriting
  • Update link exchange pages
  • PageSpeed improvements
    • Google Adsense script loading asynchronously
    • FaceBook API loading asynchronously
  • Boat Search “Modify Search” populates search criteria
  • Formatting fixes

Apache mod_pagespeed

In a previous post, I’ve been using Google’s PageSpeed Insights for a while to help optimize the page loads of my websites for a while now, but I’ve never gone so far as installing the Apache mod_pagespeed plugin.  But after trying a few different Joomla extensions, I figured this one might be more efficient by optimizing directly through the Apache layer.

mod_pagespeed is an open-source Apache module that automatically optimizes web pages and resources on them. Optimization is done by rewriting the resources using filters that implement web performance best practices. Webmasters and web developers can use mod_pagespeed to improve the performance of their web pages when serving content with the Apache HTTP Server.

Among many other features, this plugin will automatically combine/optimize how JavaScript and CSS are presented.  Afterinstalling and enabling it using .htaccess, on two of my sites so far, the pagespeed scores have increased about 6 points (from 88 to 94 on Used Boats Ahoy!), and shaved an average 500ms off page load speeds.

2012-05-24 Update:

After having good luck with this plugin on Used Boats Ahoy!, I enabled it on my other websites.  Below are the changes in PageSpeed score.
Bodhi Development: 70 to 92
Stat Addict: 74 to 90
Washington State Used Boats: 85 to 92
Quality Used Boats: 88 to 93
Bodhi Sanctum: 72 to 76
Used Boats Ahoy: 88 to 94

Website Optimization

In my previous post about Used Boats Ahoy! I mentioned a Joomla plugin Mobile Joomla! and how it can detect mobile devices and display the website accordingly without having to redirect to a subdomain..

Unfortunately since I don’t have complete control of how things are displayed due to the nature of the services I’m using, I’ve had to resort to complex CSS, and other creative solutions.  It’s proven a little more difficult than I expected to format everything just right, but even so the mobile experience is much better now than it was before.  By getting back into the code for this website, I felt it was an ideal time to look into other ways to boost my site performance.

Read more »

Used Boats Ahoy!

The site Used Boats Ahoy! is probably my most popular project to date which hasn’t required much major attention in a little while.  The latest features I’ve added were first the Facebook like/share buttons, and then the Google +1 button.

With the current trends of smartphones though, this seems to be changing.  This site was not built with the mobile web in mind (although it’s not usable).  This is a trend that I can no longer ignore, since over the last two years, mobile traffic has been doubling. Read more »

WordPress Themes