Joomla 1.6. caching implemented #jab11
-
Upload
kauselot -
Category
Technology
-
view
1.560 -
download
0
description
Transcript of Joomla 1.6. caching implemented #jab11
![Page 1: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/1.jpg)
JOOMLA! 1.6. CACHE//implemented //
![Page 2: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/2.jpg)
JOOMLA! CACHING TYPOLOGY
![Page 3: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/3.jpg)
page cache componentview cache
progressive cache
module cache
function/callback cache
output cacheraw cache
smallerunits
modules
module
functions
component
template
lim
ited
to
com
pone
nt
lim
ited
to
mod
ules
lim
ited
to
mod
ule
// Cache types coverage //
![Page 4: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/4.jpg)
page cache
// Cache types coverage //
![Page 5: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/5.jpg)
component view cache
// Cache types coverage //
![Page 6: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/6.jpg)
progressive cache
// Cache types coverage //
![Page 7: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/7.jpg)
module cachee.g. mod_latestnews
// Cache types coverage //
![Page 8: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/8.jpg)
function cacheoutputraw cache
// Cache types coverage //
Caching smaller units insideframework and extensions (not directly visible)
![Page 9: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/9.jpg)
multiple caches = multiple layers
// Cache types coverage //
![Page 10: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/10.jpg)
multiple caches = multiple layers
// Cache types coverage //
![Page 11: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/11.jpg)
PAGE CACHE
![Page 12: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/12.jpg)
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 //
![Page 13: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/13.jpg)
PROGRESSIVECACHE
![Page 14: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/14.jpg)
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. //
![Page 15: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/15.jpg)
MODULE & COMPONENT VIEW CACHE
![Page 16: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/16.jpg)
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.
![Page 17: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/17.jpg)
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) //
![Page 18: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/18.jpg)
Com_contact controler usage example:
$safeurlparams = array('id'=>'INT', 'catid'=>'INT', 'limit'=>'INT', 'limitstart'=>'INT', 'filter_order'=>'CMD', 'filter_order_Dir'=>'CMD’, 'lang'=>'CMD');
parent::display($cachable,$safeurlparams);
![Page 19: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/19.jpg)
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.
![Page 20: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/20.jpg)
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
![Page 21: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/21.jpg)
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
![Page 22: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/22.jpg)
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>
![Page 23: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/23.jpg)
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
![Page 24: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/24.jpg)
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.
![Page 25: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/25.jpg)
To use this modes rename 'cache' field in xml to
'owncache' field and call from within the module's main php file.
JModuleHelper::ModuleCache
// actually a shortcut to cache callback to avoid code duplication in every module //
![Page 26: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/26.jpg)
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);
![Page 27: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/27.jpg)
FUNCTION / CALLBACK CACHE
![Page 28: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/28.jpg)
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.
![Page 29: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/29.jpg)
Caches results of function calls
Records (cacheID) based on the arguments passed to the function
![Page 30: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/30.jpg)
Often useful to cache model methods and keep views uncached.
Example useModel 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.)
![Page 31: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/31.jpg)
OUTPUT CACHE
![Page 32: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/32.jpg)
Caches output of some part od the script
Records based on id passed
![Page 33: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/33.jpg)
Basically output buffering with caching
![Page 34: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/34.jpg)
RAW CACHE
![Page 35: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/35.jpg)
Caches any data units
Records based on id passed
![Page 36: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/36.jpg)
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
![Page 37: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/37.jpg)
Example useHigh 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 examplesExpensive queries, remote XML, thumbnails, reusable texts or any reusable data set.
![Page 38: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/38.jpg)
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.
![Page 39: Joomla 1.6. caching implemented #jab11](https://reader034.fdocuments.in/reader034/viewer/2022052307/554bc9d7b4c9053a298b599f/html5/thumbnails/39.jpg)
Raw cache get and store are easily accesed by passing '' (empty string) as cache controller to
Data is auto serialized / deserialized
Locking & unlocking are performed automaticaly
JFactory::getCache