Joomla 1.6 introduces several new caching types including:
1. Progressive cache which caches modules on a per-page basis.
2. Component view cache which caches based on safe URL parameters rather than the full URL.
3. Module cache which has additional modes like "static" and "itemid" that are set in the module XML.
4. Function/callback cache which caches the results of functions and model methods.
These caching types provide more granular control over caching different parts of the Joomla framework and extensions. The goal is to cache only reusable data and content that does not change frequently.
12. Takes snapshots of entire pages including everything -
component, modules, plugins and a template.
The widest and the least flexible approach of all caching
options.
// enabled by core system plugin -> site administrators choice //
14. Takes snapshot of each unique modules set (typicaly each
page)
Affects all modules - works as layer above module cache.
// enabled by setting cache level to progressive -> site administrators choice. For fine
grained control over each module cache use conservative caching level. //
16. Most widespread cache type, sometimes equaled with J
caching in general.
Performs well in the speed terms
Disables any
user<->extension<->framework
interaction until a cached copy has expired
Not suitable for any components or modules that react to
user actions or render frequently changing content.
17. COMPONENT VIEW CACHE
Takes an array of url parameters and their types to create
Cacheid.
A replacement for a previous unsafe way which took the
whole URL and so opened the doors for DOS attacks via
random parameters/values added to request
// Old cacheid created from URL retained for backwards compatibility if there are no
$safeurlparams (to be removed in 1.7) //
19. MODULE CACHE
5 different modes of operation, 3 of them are to be set
from module XML file, while 2 are meant to be used from
within the module itself.
Default is backwards compatible oldstatic mode that
requires no changes to a module.
20. MODES TO BE SET IN XML
Static - one cache file for all pages with the same module
parameters.
Recommended for modules that don't change.
Oldstatic - 1.5. definition of module caching, one cache
file for all pages with the same module id and user aid.
Default for backwards compatibility
21. MODES TO BE SET IN XML
Itemid - changes on itemid change.
Suitable for most dynamic modules that change per page
- like menus, breadcrumbs, content images etc
22. In addition to cache field that was required in 1.5 there is
now new hidden field in module XML called cachemode
that sets any of the above modes.
<field name="cachemode"
type="hidden"
default="static">
<option value="static"></option>
</field>
23. MODES TO BE CALLED FROM INSIDE THE MODULE:
Safeuri - id is created from URL params array, as in
component view cache
Use this mode if you module depends on url parameters
other than Itemid to display content (e.g. module that
display different image for each content category).
Modeparams property is an array of url parameters and
their filter types
24. MODES TO BE CALLED FROM INSIDE THE MODULE:
Id - module sets own cache id's according to it's own
formula.
Most flexible, but not needed often.
Modeparams property is calculated id.
25. To use this modes rename 'cache' field in xml to
'owncache' field and call JModuleHelper::ModuleCache from within
the module's main php file.
// actually a shortcut to cache callback to avoid code duplication in every module //
26. An example that uses safeuri mode
$list = modRelatedItemsHelper::getList($params) :
$cacheparams->modeparams = array('id'=>'int','Itemid'=>'int');
$cacheparams->methodparams = $params;
$cacheparams->method = 'getList';
$cacheparams->class = 'modRelatedItemsHelper';
$cacheparams->cachemode = 'safeuri';
$cacheparams = new stdClass;
$list = JModuleHelper::ModuleCache ($module, $params, $cacheparams);
28. The first of flexible caching types that enable us to
differentiate between various parts of the extension and
cache only those parts that are cacheable, while keeping
dynamic parts uncached.
29. Caches results of function calls
Records (cacheID) based on the arguments passed to the
function
30. Often useful to cache model methods and keep views
uncached.
Example use
Model performing expensive queries or similar operations
is run only once to create a larger pool of data which is
then further manipulated inside the view (sorting,
pagination, calculations etc.)
36. Fully controlled by the coder – what, when to store, how
to classify stored units (cache id).
Highly useful when we are dealing with finite number of
reusable data units
37. Example use
High number of possible combinations of relatively small
number of units – e.g. products in online store. No point
to cache multiple parameter searches, cache each product
separately.
Other examples
Expensive queries, remote XML, thumbnails, reusable
texts or any reusable data set.
38. Also useful to pass large amounts of data between
different parts of application (e.g. steps in click flow)
Used in Joomla core: list of components, list of modules,
menu tree, available languages, user groups, html
renderers etc.
39. Raw cache get and store are easily accesed by passing ''
(empty string) as cache controller to JFactory::getCache
Data is auto serialized / deserialized
Locking & unlocking are performed automaticaly