Caching for pages, blocks and menus

Caching is role based.


Types of Caching

There are two types of caching:
Block caching (for every block separately) and main content caching.


How to enable Caching

By default caching is disabled.
Caching can be enabled in following ways:
1. For block caching.
Use add or edit methods of Block module for every specific block - there should be a form element for caching with the list of roles. Select the roles for which you wish the caching to be enabled.
2. For main content caching.
Like in block caching, there are also form fields with roles for caching using add or edit methods in some modules. Select the roles for such main content for which you wish to enable caching using add or edit methods of those modules.
Such modules are for example Page and Menu.

Menus can be displayed as main contents and as blocks.
To enable caching for menus as blocks, use add or edit pages of Block module.
To enable caching for menus as main contents, use add or edit pages of Menu module.


Configure Caching

There is one default site-wide cache expiring period for every cacheable content or block.
This time period value can be changed in following way.
Go to URL [path-to-your-site]/cms/admin/list-config.
In drop-down menu "Select module" choose GlobalCore, in drop-down menu "Select type" choose Caching.
Click Edit link on the row in this table, where uri is cachePeriod.
Change the config value in minutes and click "Save changes".
Database table core_caching has actually a period field for every cacheable unit and role (block or content). It depends on every specific module then, whether its add and edit methods are letting to determine specific cache expiring periods for every unit and role or not.


Test Caching

Below are explained two simple ways to test, that Caching works for blocks and menus

Test1. Admin menu as block
Go to URL [path-to-your-site]/block/list-blocks.
Click link Edit on row: ... adminGeneralMenu ... Edit
Select admin role in form element "Caching for roles" and click save.
Make sure, that caching for adminMenu as menu is not allowed for role admin.

Edit this admin menu and change title to be "Admin2 General Menu".
If viewing this admin menu now, then title in content area should have been changed, but not in block area.
This means, that the same menu for content area was newly created with changing title, but for block it was read from cache.

Test2. Admin menu as menu
Go to URL [path-to-your-site]//menu/list-menus.
Click link Edit on row: ... adminGeneralMenu ... Edit
Select admin role in form element "Caching for roles" and click save.
Make sure, that caching for adminGeneralMenu as block is not allowed for role admin.

Edit admin menu and change title to be "Admin2 General Menu".
If viewing this admin menu now, title in block area should have been changed, but not in menu area.
This means, that the same menu for block area was newly created with changing title, but for content area it was read from cache.

If "development config variables" in config.php file are commented out, then at the end of every page it is shown in milliseconds how long it took to create that current page.
This can be used as some comparison, how much caching will make the website faster.