How to properly configure your XOOPS Cache
Requested by Mamba
and Answered by Solo71
on 2009/8/24 23:55:08
How to properly configure your XOOPS Cache
In this article we will explain how to properly configure your XOOPS Website to improve performances, using the cache system.
1) Cache principles.
2) How to configure theme’s cache.
3) How to configure modules’s cache.
4) How to configure block’s cache.
5) How to refresh cache.
1) Cache principles
There is no need to re-explain this in detail, but Xoops, like any CMS based on PHP and SQL architecture, requires a powerful enough server to perform complex queries on databases. To summarize the principle, whenever a user clicks on a page, it sends queries to the database on the server. This calculates the request’s result and sends it back as an html file (or text form in some cases), which is read by the browser user.
The speed of page display of a website depends on several parameters, which are, for example:
- Connection’s performance ;
- Web server performance (the machine itself and how many sites are hosted on this machine, unless you benefits from a dedicated machine);
- Server’s Performance hosting the SQL database;
- The quality of pages code and weight (many pictures or text only).
Since its 2.0.x version, XOOPS uses a template system that accelerates pages’ display.
While using the cache system, query results are stored in a temporary directory, thereby reducing the total number of request. Starting in XOOPS 2.3, the cached files are stored in directories:
* templates_c: the directory containing all the temporary theme files.
* cache: contains blocks and modules buffer. If you do not use the cache opption, this directory will remain empty.
For instance, when you are on the home page, if you disable the caching systems on each and every used modules and blocks, you will easily get up to a hundred requests (depending on the number of blocks displayed of course) each time a user requests this page. Configured properly, the modules and blocks caching will reduce this figure to quarantine on average. This will greatly improve the response time of your website.
2) How to configure theme’s cache
The theme of your site is stored in a default cache directory. To ensure this option is active, go to 'Admin / System Admin / Preferences / General Settings' in your admin panel. Locate the line 'Update Files Game Themes from the directory themes?’ and tick 'No'.
If this option is enabled, theme files are going to be automatically updated if your current theme files are modified. Ideally, that option must be idle when the site is publicly accessible.
3) Configure Cache Modules
XOOPS allows you to implement a cache system on a module as a whole. To change this setting, go to 'Admin / Admin System / Preferences / General Settings'. There, scroll to the bottom of the page and you will see the option 'Cache off modules'. You can edit the general parameters for each and every modules installed on your website. The system then puts the contents of a cached module for a definable period of time.
Available time cache
To help you properly configure your cache settings, go to 'Admin / System Admin / Preferences / General Settings' and select mode focusing on ' MySQL / Blocks'.
Use caching with caution. XOOPS is by definition a system based on dynamic content. Your settings depends on the interactivity rate. Using a 30 seconds cache can be justified on modules with strong traffic and frequent refreshments: a module on home page, for instance. In the other hand, a 1 week’s choice is better for more 'static' modules’ content. For instance, content which is updated by webmaster (you) or co-admin: sections, html pages manager, FAQ, etc. In this case, you can refresh the cache manually (see point 5). Remember that counters the page (if any) will also be affected by caching (if cached, no counter)...
Here are some suggestions for some standard XOOPS modules :
Pay attention to the fact that your settings will depend on the level of responsiveness that you want to give your members bid... Also remember that comments are not affected by cache modules!
4) How to configure block’s cache
This is probably where the cache system the most efficient. Each and every generated block can be independently cached. Usage is slightly different from the above modules, as they allow you to put cache on modules’ blocks which are not even cached (and conversely). That is you can have cache on a module but not on their depending blocks. Thus, the 'gap' risk is more evident.
Available time cache
1 month *
* Note that, surprisingly, you have a 1 month option for blocks but not for modules.
Regarding blocks, some functions require real-time access to work properly. For example, never use the cache (or very low cache time) in the following occasions:
- Comments and topics from forums. This can be very disturbing for users who do not see their answers appear in these blocks. From experience, they will tend to repost their reply, thinking it was not correctly stored.
- Login, user menu and main menu (if dynamic). These blocks are particularly reactive to requests from users. Any cache would produce unexpected results.
- The 'Who's Online'’s block. A specific block that works in real time for obvious reasons.
- Chat box.
- All blocks using random functions (pictures, quotes, data, etc..).
On the other hand, you should allocate to block’s cache for which rapid updating is secondary. Again, you might consider updating it manually if necessary (see point 5).
- Block type 'Last published or Top 10' (Downloads, Links, articles, etc.). That kind of information does not really require dynamic aspect or immediacy of result. The cache will find its usefulness.
- The custom blocks with static content (welcome texts, custom links, news, etc..), you can select a long time cache.
It’s up to you to decide what priority you give to your block information.
5) How to refresh cache
To refresh cache (modules and blocks), simply go into 'Admin / Admin System / Preferences / General Settings' and press 'Go!'.
For sections which are updated by webmasters, put a maximum cache (1 weeks – 1 month). Disable cache during update, and when new submission is ready, turn the cache back on.
Pay attention to modules which display admin links on user page. Do not turn cache on while you are checking those pages as an admin. As a draw back, all those “admin only” links would display till the cache expiration, even for your anonymous users!
Finally, as recommended by the development team Xoops:
"If you are using the cache feature, clear cached files by periodically updating the general preferences in" System admin "=>" preferences "for better performance."
This Q&A was found on XOOPS Web Application System : https://xoops.org/modules/smartfaq/faq.php?faqid=771