Sticking to this weeks theme of speeding up your website, I thought I would address the most likely source of all our visitors, Google. Google may not be your primary source of visitors, but I’m sure you are getting at least a fair percentage of your traffic from them.
To make sure they are happy with your site, a good start would be to make sure you have taken their recommended steps to ensure your site is optimized for fast loading.
Google’s First Recommended Tip is to Optimize Caching
The first tip Google recommends is to optimize caching. By getting content that is repeatedly seen by the user, caching it on their PC is a great way to eliminate recurring downloads. Having a user download an image or script repeatedly for every page viewed is a brutal experience for a user with slow access. Even with cable or DSL, seconds saved by caching can very rapidly add up, and improve a users experience.
Another form of caching is where your dynamic content is cached as a static page. This speeds things on on the server side, reducing individual requests to content and your database.
With caching you reduce page file size, and total number of HTTP requests. The result is faster downloads, faster browser rendering, and a win for your users.
How To Cache Your Content
This blog is run by WordPress, and for those of you that use WordPress as well, here is an easy fix. Just search the plugin directory from your dashboard for WP Super Cache. Install it, follow its easy directions, job done.
For those of you not using WordPress (most of you?), a decision needs to be made on what type of content you are going to cache. Do you want to cache the content, database queries, or both. I don’t personally cache database queries. What I like to do is let the database queries run naturally, and when the more complex and repetitive queries kick in, I assign a cron file to periodically complete the query writing a new file every time. The effect is pretty much the same.
Too Complex, Where to Start?
So some of you may be thinking this is just too complicated. It can be kind of a pain, but here is a good little sampler that anyone should be able to handle, assuming your site is on an Apache server. Try setting up your image folder to cache images loaded. If you don’t have this file already in your image folder, you will need to create one called “.htaccess”.
Within the .htaccess file, paste in the following:
ExpiresDefault “access plus 2592000 seconds”
ExpiresByType image/gif “access plus 2592000 seconds”
ExpiresByType image/jpeg “access plus 2592000 seconds”
ExpiresByType image/png “access plus 2592000 seconds”
ExpiresByType text/css “access plus 2592000 seconds”
# Cache specified files for 30 days
Header set Cache-Control “max-age=2592000, public”
I included the CSS line so you can see how I cache that as well. Numbers are set for seconds, and Google suggests 1 month. I have mine set for 30 days. Did it work? Don’t know how to test? Comically, testing it can be a bit of a chore itself. However, if you use Firefox, and have the Firebug plugin, testing it is just a click a way. For more information about testing, and downloading Firebug see my post: Webmaster tools Sites Performance.