phpBB3 Optimization Tutorial

How to speed up phpBB3

In this tutorial we'll give you some suggestions on how to speed up and optimize phpBB3. Many of the tips are general and can be applied to other Content Management Systems (e.g. Joomla, WordPress, Magento, etc.) and some are phpBB3 specific. It's worth mentioning that you don't really need to take any optimization measures, unless your board is really getting big and it has thousands of registered users and/or you have installed some mod that slows down your whole forum. Trying to optimize and speed up a small board may sometimes give the opposite results.

Update

Whenever there's a new upgrade release don't wait too long to update your phpBB3 board. Upgrade packages have various improvements in terms of optimization, security and others. If you need help with updating your phpBB3, check out the tutorials on updating phpBB3 with an automatic update package or updating phpBB3 through SSH, depending on your preferred method.

MODs

MODs (or modifications) are a great way to add different features and functionalities to your site. However, you shouldn't install too many of them just for the sake of it. Depending on the MODs, the more MODs you have, the more database requests; each additional request slows down your site. So install MODs that you really need or like, and if there are any that you don't need any more, uninstall them. To learn how to install MODs read the tutorial on installing phpBB3 MODs manually, or if you prefer the automatic way, check out the tutorial on installing phpBB3 MODs with AutoMOD.

GZip Compression

By enabling gzip compression the data transfer between the server and the client will be compressed. You can turn on gzip compression from the administration control panel of your phpBB3 board. For some more details read the article on enabling gzip compression in phpBB3.

Search Function

Another thing you can do is to disable the search function for guests and leave it for registered users. You can do this by adding some code in the search.php file, which is in the root phpBB3 directory on your hosting account. For example, if your phpBB3 board is installed in a folder called phpbb3 in the root public_html directory on your account, the path to the file would be public_html/phpbb3/search.php.

You can edit the file from the Files section of the HostKnox control panel. Click on the name of the file with the left mouse button, make the change and then click on Save Content or on the Save and Close button. Alternatively, you can download the file with an FTP client (e.g. FileZilla), then edit it with a text editor (e.g. Notepad), save it and upload it back, overwriting the old file.

To disable the search function for guests, open the search.php file and find the following line:

// Check search load limit

On a new line after it add the following code:

if ($user->data['user_id'] == ANONYMOUS)
{
$template->assign_var('S_NO_SEARCH', true);
trigger_error('NO_SEARCH');
}

After you make the change and save the file, log out of your phpBB3 board (if you're logged in), and check the search function as a guest.

Avatars and Attachments

An avatar is a small image displayed under the name of the user when he/she posts a message in a forum on your board. By default, avatars are disabled in phpBB3. If you enable phpBB3 avatars this means that when somebody browses a topic in a forum on your board, the avatar images also have to be loaded. This may increase the page loading time, although your board has to be really big for this to be of some concern. Most boards offer the avatar feature, so you have to decide what's best for your board and users. What you can do, however, after you enable the use of avatars, is to change the dimensions and maximum size of avatars that people can upload.

On the Avatar settings page of the admin panel you'll notice that the default minimum avatar dimensions are 20x20 pixels (width x height) and the maximum are 90x90. The maximum avatar file size is set to 6144 bytes (or 6 kilobytes). If this is of concern to you and you have many users, you can reduce the maximum avatar file size.

Avatar Settings

Attachments on the other hand are enabled by default. To change attachment settings, log in to your administration control panel, click on the Posting tab at the top and on the new page click on Attachment settings on the left:

Attachment Settings

One of the things you can do is to disable the display of images inline and show them as links instead. By default, if someone attaches an image, the whole image will be displayed under the text of the post. As you can guess, the more graphics there are on the page, the longer it will take for it to load. You can, however, configure the settings so that when someone attaches an image only the link will be displayed under the post, and if someone wants to see it or download it, they just have to click on the link. For more information on how to change this setting read the article on displaying attached images as links in phpBB3.

From the Attachment settings, if you think it burdens your board, you can also disable attachments altogether. Just mark the button Yes for the option Allow attachments. Or if you leave it enabled you can reduce the total attachment quota and/or the maximum file size of the attachments that can be uploaded. You can also reduce the maximum number of attachments per post; the default is three.

Prune Forums

If your board is getting too big you can prune old forums. This, of course, also depends on the type of board and on your personal preferences. If there are forums with old but valuable topics, it might be better for your users to keep them. If there are old and useless topics that you don't need, it might be a good idea to clean up your board.

To prune forums, log in to the administration control panel, click on the Forums tab and then on the Prune forums link on the left. From the forum list that appears mark the forum/forums that you want to prune and click on the Select a forum button. A new page with some options will open. Specify the days since the last post or/and the days since the topic was last viewed and click on the Submit button. This will delete all the topics that meet the requirements in the chosen forums.

Prune Forums

From the settings of a forum you can also configure it to be pruned automatically when the specified requirements are met (e.g. 200 days since last post).

FastCGI

By default HostKnox accounts use plain CGI. You can, however, enable FastCGI from the PHP Settings section of the HostKnox control panel. FastCGI speeds up PHP applications. You can switch between the two any time you like.

Optimize the MySQL Database

Optimize the MySQL database used by your phpBB3 application regularly. Especially on a large board, this can significantly improve the speed. To learn how to do it read the second part of the tutorial on repairing and optimizing MySQL databases with phpMyAdmin.