XOOPS: Optimizing Xoops, its modules and your server

Posted by: instantzeroon 2007/12/17 16:26:27 11220 reads
Sometimes, people are telling that Xoops is rather slow and it can be true but there are ways to improve things.

Instant Zero is in charge to maintain some websites using Xoops, so we decided to share with you our knowledge in this domain and we hope that you will find it useful.

In this article, and in 5 points, you are going to see what you can do for your site.

1/ the server
We are first going to look at your server and what you can do with it.
Depending of the type of server and contract you have, we recommend you to activate the gzip compression.
If your server is running Apache 2, then you need to activate the deflate module.
We will not talk of how to install and use it; you will find many good tutorials for this on internet.

“Modern” browsers (in fact it's running with not so recent browsers) can ask to the web servers to send then the page compressed.
There are many advantages of this, first there are fewer connections between the server and your navigator and secondly, you receive less data.
The counterpart of this is that you ask more work to your server. But it deserves it!
It's like compressing an html page with any zip program and sending it to your browser.
That's exactly the same and your browser surely can do it. For your server ... you have to see with your host.

If you can, we also recommend you to install and to use the Zend Optimizer or the eAccelerator extension.
Php6 should come with an opcode cache but until it is here, try to use another method to win some time.
With the Zend optimizer (or any other opcode caching system), the script which are the most used stay in memory in a precompiled state. Like this, your site does not need to interpret each script each time it is called.
With a Php extension like eAccelerator, ALL the Php scripts called by your site can be saved in a “compiled” state to your hard disk. It requires as many disk space as you have scripts (and even a little more), but it's also a great help to have a quicker site.

2/ Xoops by itself
The problem with CMS is that everything is dynamic, so the database is often used, and it's also true with Xoops.
But Xoops uses a template system called “Smarty” and this one enables you to use a caching system.
Whereas this cache system can cause problems when it is globally used on modules pages, it can be very useful on your modules blocks.
And often, you site's top page uses many blocks.
So don't forget to apply some cache to your blocks, you can do it in the Xoops blocks manager, edit the block and select a cache duration.
One last recommendation, on many website for which we are doing maintenance, we can see this option activated “Check templates for modifications?”
Definitively, except if you are working on your theme, deactivate this option (set it to No)!

3/ Database
Your database is called on every page. It is called by Xoops and by your modules.
With time and use, your database can become “unoptimized“, so we first recommend you to install and configure XoopsCare.
With this module, you can plan some regular optimizations process for your database.

There's something you must know, if you have a crash problem with your database one day, it's easier (when it's possible) to recover data from a database which is often optimized than from a database which is never optimized and it's quicker for your site.

Depending of the traffic your site has, you can select a greater of lower value for the “Maintain database every ...” option. We also recommend you to use the “Cache and Templates_c” option and the “Emtpy Sessions”
While we are talking of sessions, the longer session you set, the greater (and longer) your database you fill!
And don't forget that a robot like Google uses sessions ...

Still when talking of the database, we are going to finish this section of this article with some optimizations you can bring to the Mysql tables used by Xoops and the modules installed on your website.

Before to do any change on your database, we strongly advise you to do a full backup of it (content and structure).

As you may know, Xoops uses a database for its content. The modules too.
Each module has its own Mysql tables. It consists of a structure (a name and fields) and of data.

Each table can have as many indexes as you want.
Indexes are used to get quicker searches but as a counterpart, what you win during the reading process is lost when you insert data because you need to insert data in the table and to update the index.
But often, your website is more used in reading than in writing. So if you have speed problems with your site, then you can add some indexes where it can be useful.

So, to add indexes to your site, and after you made the backup, we recommend you to use a script like Phpmyadmin to add indexes to your tables.
Adding indexes is a very simple operation. Once you have clicked (on the left) on the table's name, then its structure is visible on the right and you will see a link, or an icon, to add an index on the desired field(s).

We are going to see the Xoops tables where you can add some indexes and what fields you can index.

a) The “modules” table (something like “xoops_modules” on your site, depending of the prefix you used during the installation but in this article we will call it “xoops”). In this table, the modules installed on your site are declared. You can add index to those 3 fields, “isactive”, “weight” and “hascomments”.

b) xoops_users. This table stores the list of all the users of your site. You can index the “level” field.

c) xoops_online. This table is used by the “who is online block” (and its content is only filled when this block is visible). You can index the fields “online_updated” and “online_uid”

d) Xoops_config. In this table, are saved all the configurations, for Xoops and for the modules. You can add index to the “conf_order” field

e) xoops_xoopscomments. As the name suggest, this table contains the comments of all the modules. You can index the “com_status” field

f) Now we are going to see some tables' modules. First, multiMenu. That's a very popular module that you can use to create, as the name suggest, some menus. On the tables of this module, you can index the “weight”, “hide” and “submenu” fields.

g) News. The News module is also a well known module to create articles. You can add an index on the field “published” of the “xoops_stories” table.

h) extCal is an excellent agenda. In the “xoops_extcal_event” table, you can index “event_start”, “event_end”, change “event_approved” from int(11) to tinyit(1) and index it. You can also index the “cat_id” field. If you want, you can also add another index composed of “event_start” + “event_end” + “event_approved“

i) Smartsection, this is a module used to create pages. In its table called xoops_smartsection_items, you can index the “status” and “datesub” fields. Still in this module, in the table called “xoops _smartsection_categories”, you can index the “parentid” and “weight” fields.

j) XoopsPoll, this is a module used to create polls. In its table called xoops_xoopspoll_desc, you can index the “weight” field.

k) Newbb. This is forum for Xoops. In its table called “xoops_bb_online”, you can add an index on the “online_uid” field and in its table called “xoops_bb_topics” you can index the “approved” field. For the “xoops_bb_posts” table, you can index the “approved” field. Finally, in the table called “xoops_bb_forums”, you can add an index on the “parent_forum” field.

l) Catads. This is an excellent module to make ads. In the “xoops_catads_ads” table, you can index the “waiting”, “published”, “expired”, “uid” and “cat_id” fields. In its table called “xoops_catads_cat”, you can add index to the “weight” and “pid” fields

m) SmartFAQ is a FAQ module, in its table called “xoops_smartfaq_categories”, you can add an index on the “parentid” field.

This is not a complete list. You can surely find tables which need more indexes and even tables without indexes.
If you are a developer or an experience user, you can activate the “slow queries log” of your Mysql installation.
If you are not a developer or an experienced user, then, you can at least see, via Phpmyadmin, if the tables used by your site have indexes.

4/ Files used
Some files are used on every page, that's the case of the file xoops.js.
You can find this file on your website, in the “include” folder.
If you use a standard theme, then this file is called on every page of your site.

With a program like jsmin, you can “minify” its size.
This can seems ridiculous but on website with many traffic, it can help your site to run faster.

You can apply jsmin on any other Javascript file you are using, for example jQuery or Prototype.
As a general role, for Javascript files, place these files as low as possible in the code of your theme.
You can also apply this rule to the Google Analytics code (if you use it) and to Google Ads.

Another kind of file that is used by your websites, that's pictures.
Try to reduce your pictures weight as much as possible.
If you are working with Photoshop, then export them for the web and try to compress them as much as possible.
If you are not using Photoshop, then I recommend you to use XnView (available under Windows and Linux).

5/ CSS
Your site certainly use a CSS file called from your theme. Verify that this file does not contain too many comments and remove them if necessary.
Place the call to your CSS files at the very top of your theme, this is a way to win some time.

Don't hesitate to contact us if you need some services for Xoops.

Instant Zero, your Xoops specialist.