Optimizing Xoops, its modules and your server


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 serverWe 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 itselfThe 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/ DatabaseYour 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 usedSome 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/ CSSYour 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.

ConclusionDon't hesitate to contact us if you need some services for Xoops.Instant Zero, your Xoops specialist.
Postar um comentário