Actions

Difference between revisions of "Cache"

From Joomla! Documentation

m (Adjusted category)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
Joomla has different ways of caching "things".  Here is an overview for administrators and developers, what, where and when..
+
;Joomla has different ways of caching "things".  Here is an overview for administrators and developers, what, where and when..
  
=Cache partly broken=
 
{{notice| All cache storages except filecache are broken in Joomla 1.5. Though they are all redirected to the filecache since a certain 1.5 version, there still seem to be some problems with this workaround. (See [[Talk:Cache]])}}
 
 
=For Administrators=
 
=For Administrators=
 
A Joomla administrator can use these caches and options:
 
A Joomla administrator can use these caches and options:
Line 34: Line 32:
  
 
=For Developers=
 
=For Developers=
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.
+
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'').
 
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.
+
*'''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:
 
This can automatically be done via the base controller's display function. For example in the controller of your component:
 
<source lang="php">class DeliciousController extends JController {
 
<source lang="php">class DeliciousController extends JController {
Line 44: Line 42:
 
}
 
}
 
}</source>
 
}</source>
*'''[[JCachePage]]''' caches and returns the body of the page.
+
*'''JCachePage''' caches and returns the body of the page.
*'''[[JCacheCallback]]''' caches and returns the output and results of functions or methods.
+
*'''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]]
 
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.
+
*'''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.
 
This is rather meant for caching a specific part of php code. It acts like an output buffer, but cached.
 
+
<headertabs/>
=References=
+
==References==
 
* [http://forum.joomla.org/viewtopic.php?f=428&t=326990&start=0 Better performance with joomla System Cache plugin (Joomla Forum)]
 
* [http://forum.joomla.org/viewtopic.php?f=428&t=326990&start=0 Better performance with joomla System Cache plugin (Joomla Forum)]
* [[JCache]]
+
* [http://api.joomla.org/Joomla-Platform/Cache/JCache.html JCache]
  
 
[[Category:Landing Pages]]
 
[[Category:Landing Pages]]
[[Category:Development]]
+
[[Category:Extension development]]
[[Category:Cache]]
+
[[Category:Manual]]
+
 
[[Category:Global Configuration Management]]
 
[[Category:Global Configuration Management]]
 
[[Category:Framework]]
 
[[Category:Framework]]

Latest revision as of 15:02, 7 August 2013

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..

Contents

For Administrators

A Joomla administrator can use these caches and options:

Page Caching

  • 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

  • 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

  • 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

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

  • 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

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.
        }
}
  • 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