Wednesday, February 22, 2012

Quickly and Greatly speed up your XenForo

A default setup of XenForo statistics and speed:
Total Page Size: 357kb
http://gtmetrix.com/reports/xfproud.com/Dpk7form

After this guide:
Total Page Size: 172kb
http://gtmetrix.com/reports/xfproud.com/vmWjnTCF
After this guide your site should be loading almost instantly. Even a larger site. There are other server side methods to speed up your site but these are simple and quick fixes. I repeated all this and created the guide in less than an hour.

XFOptimize
A must have. This will compress whitespace and javascript on your site and cause noticeable differences right away.
http://xenforo.com/community/threads/xf-optimise.14021/

Remove Sidebar Share Page
This is a simple way to increase your front page load time. Simply open the template sidebar_share_page and delete its content. Anytime you would like to re-add this to the sidebar, simply revert the template.

By doing this you will minimize DNS look up on the front page.

Host Jquery with google
By not hosting the file yourself and by allowing google to host it, users that have downloaded it from google before will load it a lot faster. To change this go into your Admin Panel and navigate to Home > Options > Performance. Set the Jquery source to Google Ajax API CDN.

Cookie Free Domain
This is rather tedious way to speed up your site but a great way one.

1. Create a subdomain (if you don't know how to do this, contact your host provider). I generally name mine static. So it'll be http://static.YOURSITE.com
2. Move your skin folder and XenForo folder to the root of the subdomain folder.
3. In your admin control panel go to Appearance > Style Properties > General > Settings > Path to Image. Change it to http://static.YOURSITE.com
4. Now go to Header and Navigation change the logo paths to http://static.YOURSITE.com/xenforo/logo.png
5. Now go to Forum List and change each forum icon path to http://static.YOURSITE.com/xenforo/widgets/FORUMICON.png
6. After using XFOptomize, move your js folder to your subdomain folder. In your Admin Panel, navigate to Home > Options > Performance. Set the option_JavascriptSource to http://static.YOURSITE.com/js
7. If you use a custom skin go you'll have to go through and find any custom image and change its link tohttp://static.YOURSITE.com/CUSTOMSKIN/IMAGELINK

Check GTMetrix under YSLOW tab > 'User cookie-free domain' to ensure all images are part of a cookieless domain.

Compress your images with Smush.it
smushed.png 
Smush.it compresses your images to help quicken the load time. GTMetrix will help with images not compressed, but for all other default XenForo images, I have uploaded them here. I'll try to keep this up to date as often as possible.

Cache Control and Header Expires
Simply adding Cache Control and header expire to your .htaccess file can greatly speed up your sites speed by cacheing just about everything. Here is my current set up, add it to the top of your file.

It is recommended that you do this last. Your members may have larger files and older non compressed images cached if you do this at the start.

Code:
Header unset Pragma
FileETag None
Header unset ETag

# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS 172800
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=604800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Dec 2011 20:00:00 GMT"
</FilesMatch>

No comments:

Post a Comment