Difference between revisions of "Cache"

From Joomla! Documentation

(New page: {{incomplete}} Joomla has different ways of caching "things". Here is an overview for administrators and developers, what, where and when.. =For Administrators= A Joomla administrator ca...)
 
(Marked this version for translation)
(22 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{incomplete}}
+
<noinclude><languages /></noinclude>
Joomla has different ways of caching "things".  Here is an overview for administrators and developers, what, where and when..
+
{{review}}
 +
<translate>
 +
<!--T:1-->
 +
;Joomla has different ways of caching "things".  Here is an overview for administrators and developers, what, where and when.
 +
</translate>
  
=For Administrators=
+
<translate>
 +
=For Administrators= <!--T:2-->
 
A Joomla administrator can use these caches and options:
 
A Joomla administrator can use these caches and options:
==Page Caching==
+
</translate>
 +
<translate>
 +
==Page Caching== <!--T:3-->
 
*'''Configuration''': Built-in Plugin (Extensions -> Plugin Manager -> System - Cache)
 
*'''Configuration''': Built-in Plugin (Extensions -> Plugin Manager -> System - Cache)
 
*'''Caches''': each whole page of your site
 
*'''Caches''': each whole page of your site
Line 11: Line 18:
 
**Optional browser caching: Also caches on your visitors' browser/computer
 
**Optional browser caching: Also caches on your visitors' browser/computer
 
**Only caches pages for guest visitors (not for logged in visitors)
 
**Only caches pages for guest visitors (not for logged in visitors)
 +
</translate>
  
==View Caching==
+
<translate>==View Caching== <!--T:4--></translate>
 +
<translate>
 +
<!--T:5-->
 
*'''Configuration''': Global Config->Cache
 
*'''Configuration''': Global Config->Cache
 
*'''Caches''': each view of a component
 
*'''Caches''': each view of a component
 
*'''Based on''': URL, view, parameters, ...
 
*'''Based on''': URL, view, parameters, ...
*'''More info''': Component developers have to include this in their code to work. Mostly this is not done.  The Joomla main content component uses this, but only for guest visitors of your site though this is not obligated for every component.  
+
*'''More info''': Component developers have to include this in their code to work. Mostly this is not done.  The Joomla main content component uses this, but only for guest visitors of your site though this is not obligated for every component.
==Module Caching==
+
</translate>
 +
<translate>
 +
==Module Caching== <!--T:6-->
 
*'''Configuration''': Global Config->Cache
 
*'''Configuration''': Global Config->Cache
 
*'''Caches''': each module (individually customized via each module's Advanced Parameters)
 
*'''Caches''': each module (individually customized via each module's Advanced Parameters)
 
*'''Based on''': ?
 
*'''Based on''': ?
 
*'''More info''': You must disable it on some modules to avoid problems
 
*'''More info''': You must disable it on some modules to avoid problems
==Further Caching==
+
</translate>
If you want to check out other chache systems and possibilities, you might want to check out the third-party extensions around caching.
+
<translate>
==Caching engines or storages==
+
==Further Caching== <!--T:7-->
 +
If you want to check out other cache systems and possibilities, you might want to check out the third-party extensions around caching.
 +
</translate>
 +
<translate>
 +
==Caching engines or storages== <!--T:8-->
 
*'''Configuration''': Global Config->Cache
 
*'''Configuration''': Global Config->Cache
 
Here you can choose which system you want your site to use for all caching.  Current options are: APC, Eaccelorator, File, Memcache, XCache.
 
Here you can choose which system you want your site to use for all caching.  Current options are: APC, Eaccelorator, File, Memcache, XCache.
 +
</translate>
  
 +
<translate>
 +
<!--T:9-->
 
APC, for example, also caches your php opcode.
 
APC, for example, also caches your php opcode.
 +
</translate>
  
 +
<translate>
 +
=For Developers= <!--T:10-->
 +
The class '''JCache''' allows a lot of different sorts and levels of caching.  The following sub-classes are made specifically, but you can add your own, or use the main one in many different ways.
 +
</translate>
  
=For Developers=
+
<translate>
The class '''[[JCache]]''' allows a lot of different sorts and levels of cachingThe following sub-classes are made specifically, but you can add your own, or use the main one in many different ways.
+
<!--T:11-->
 +
Don't forget that the first level of cache encountered, will override any deeper caching.  I suppose that too many levels is also counterproductive (''to be verified though'').
 +
</translate>
 +
<translate>
 +
<!--T:12-->
 +
*'''JCacheView''' caches and returns the output of a given view (in MVC)A cache id is automatically generated from the URI, specific view and its specific method, or you can give your own.
 +
</translate>
 +
<translate>
 +
<!--T:13-->
 +
This can automatically be done via the base controller's display function. For example in the controller of your component:
 +
</translate>
  
Don't forget that the first level of cache encountered, will override any deeper caching.  I suppose that too many levels is also counterproductive (''to be verified though'').
 
*'''[[JCacheView]]''' caches and returns the output of a given view (in MVC).  This can automatically be used via the base controller ( display(true) ). For example in the controller of your component:
 
 
<source lang="php">class DeliciousController extends JController {
 
<source lang="php">class DeliciousController extends JController {
 
function display() {
 
function display() {
Line 41: Line 73:
 
}
 
}
 
}</source>
 
}</source>
*'''[[JCachePage]]''' caches and returns the body of the page.
 
*'''[[JCacheCallback]]''' caches and returns the output and results of functions or methods.
 
If you want to cache queries, this is a good class for it, as illustrated here: [[Using caching to speed up your code]]
 
*'''[[JCacheOutput]]''' caches and returns output.
 
This is rather meant for caching a specific part of php code. It acts like an output buffer, but cached.
 
 
 
=References=
 
* [http://www.theartofjoomla.com/joomla-caching-explained.html|Joomla caching explained]
 
* [http://forum.joomla.org/viewtopic.php?f=428&t=326990&start=0|Better performance with joomla System Cache plugin (Joomla Forum)]
 
* [[JCache]]
 
  
 +
<translate>
 +
<!--T:14-->
 +
There are also some urlparams to consider. Check this [http://joomla.stackexchange.com/questions/5781/how-can-i-use-joomlas-cache-with-my-components-view/7000#7000 "joomla stack"]
 +
</translate>
  
 +
<translate>
 +
<!--T:15-->
 +
Also, be aware that any updates (such as hits or visit counts) will NOT be updated (unless you add this outside this method and thus any deeper MVC-part.)
 +
</translate>
 +
<translate>
 +
<!--T:16-->
 +
*'''JCachePage''' caches and returns the body of the page.
 +
*'''JCacheCallback''' caches and returns the output and results of functions or methods.
 +
If you want to cache queries, this is a good class for it, as illustrated here: [[S:MyLanguage/Using caching to speed up your code|Using caching to speed up your code]]
 +
</translate>
 +
<translate>
 +
<!--T:17-->
 +
*'''JCacheOutput''' caches and returns output.
 +
This is rather meant for caching a specific part of php code. It acts like an output buffer, but cached.
 +
</translate>
 +
<headertabs/>
 +
<translate>==References== <!--T:18--></translate>
 +
<translate>
 +
<!--T:19-->
 +
* [http://forum.joomla.org/viewtopic.php?f=428&t=326990&start=0 Better performance with joomla System Cache plugin (Joomla Forum)]
 +
* [http://api.joomla.org/Joomla-Platform/Cache/JCache.html JCache]
 +
* [http://joomla.stackexchange.com/questions/5781/how-can-i-use-joomlas-cache-with-my-components-view/7000#7000 How can I use Joomla's Cache with my components view? (joomla stackexchange beta)]
 +
</translate>
  
<noinclude>[[Category:Development]] [[Category:Cache]] [[Category:Manual]]</noinclude>
+
<noinclude>
 +
<translate>
 +
<!--T:20-->
 +
[[Category:Landing Pages]]
 +
[[Category:Extension development]]
 +
[[Category:Global Configuration Management]]
 +
[[Category:Framework]]
 +
</translate>
 +
</noinclude>

Revision as of 18:19, 16 May 2015

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎eesti • ‎español • ‎français • ‎italiano • ‎português • ‎русский • ‎فارسی • ‎हिन्दी • ‎中文(台灣)‎
Copyedit.png
This Article Needs Your Help

This article is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.


Joomla has different ways of caching "things". Here is an overview for administrators and developers, what, where and when.

For Administrators[edit]

A Joomla administrator can use these caches and options:

Page Caching[edit]

  • Configuration: Built-in Plugin (Extensions -> Plugin Manager -> System - Cache)
  • Caches: each whole page of your site
  • Based on: URL
  • More info:
    • Optional browser caching: Also caches on your visitors' browser/computer
    • Only caches pages for guest visitors (not for logged in visitors)

View Caching[edit]

  • Configuration: Global Config->Cache
  • Caches: each view of a component
  • Based on: URL, view, parameters, ...
  • More info: Component developers have to include this in their code to work. Mostly this is not done. The Joomla main content component uses this, but only for guest visitors of your site though this is not obligated for every component.

Module Caching[edit]

  • Configuration: Global Config->Cache
  • Caches: each module (individually customized via each module's Advanced Parameters)
  • Based on: ?
  • More info: You must disable it on some modules to avoid problems

Further Caching[edit]

If you want to check out other cache systems and possibilities, you might want to check out the third-party extensions around caching.

Caching engines or storages[edit]

  • Configuration: Global Config->Cache

Here you can choose which system you want your site to use for all caching. Current options are: APC, Eaccelorator, File, Memcache, XCache.

APC, for example, also caches your php opcode.

For Developers[edit]

The class JCache allows a lot of different sorts and levels of caching. The following sub-classes are made specifically, but you can add your own, or use the main one in many different ways.

Don't forget that the first level of cache encountered, will override any deeper caching. I suppose that too many levels is also counterproductive (to be verified though).

  • JCacheView caches and returns the output of a given view (in MVC). A cache id is automatically generated from the URI, specific view and its specific method, or you can give your own.

This can automatically be done via the base controller's display function. For example in the controller of your component:

class DeliciousController extends JController {
	function display() {
		parent::display(true); //true asks for caching.
	}
}

There are also some urlparams to consider. Check this "joomla stack"

Also, be aware that any updates (such as hits or visit counts) will NOT be updated (unless you add this outside this method and thus any deeper MVC-part.)

  • JCachePage caches and returns the body of the page.
  • JCacheCallback caches and returns the output and results of functions or methods.

If you want to cache queries, this is a good class for it, as illustrated here: Using caching to speed up your code

  • JCacheOutput caches and returns output.

This is rather meant for caching a specific part of php code. It acts like an output buffer, but cached. <headertabs/>

References[edit]