DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:caching

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:caching [2021-12-01 22:10] – removed unrelated tip andidevel:caching [2025-02-11 08:44] (current) – 2 spaces 217.175.54.43
Line 8: Line 8:
   http://www.example.com/namespace/page?purge=true   http://www.example.com/namespace/page?purge=true
  
-Some of your URL might look like this ''?id=pagename'' then use ''&'' between parameters:+Some of your URL might look like this ''?id=pagename'' then use ''&'' between parameters. Note that order does not matter. Both examples below are valid and produce the same result:
  
   http://localhost/dokuwiki/doku.php?id=my_page_name&purge=true   http://localhost/dokuwiki/doku.php?id=my_page_name&purge=true
 +  http://localhost/dokuwiki/doku.php?purge=true&id=my_page_name
  
 To force recaching of all pages, including page instructions, [[man>touch]]((Non-Unix users can simply open the file and save it again -- the idea is to change the file's timestamp)) the local configuration file, ''conf/local.php''. Saving the configuration settings form over the [[plugin:config|admin interface]] will have the same effect. To force recaching of all pages, including page instructions, [[man>touch]]((Non-Unix users can simply open the file and save it again -- the idea is to change the file's timestamp)) the local configuration file, ''conf/local.php''. Saving the configuration settings form over the [[plugin:config|admin interface]] will have the same effect.
 +
 +**Note:** There is the [[plugin:stale|stale plugin]] providing a one-click-action for this purpose.
  
 To only force recaching of page xhtml, touch ''inc/parser/xhtml.php''. To only force recaching of page xhtml, touch ''inc/parser/xhtml.php''.
Line 18: Line 21:
 To purge the editor toolbar (and other cached JavaScript) call To purge the editor toolbar (and other cached JavaScript) call
   http://www.example.com/lib/exe/js.php?purge=true   http://www.example.com/lib/exe/js.php?purge=true
-and clean up your browser's cache as well. This especially helps if a new button introduced by a plugin does not show up.+and clean up your browser's cache (Ctrl+F5) as well. This especially helps if a new button introduced by a plugin does not show up.
  
 You can also clear the CSS cache in the same way: You can also clear the CSS cache in the same way:
   http://www.example.com/lib/exe/css.php?purge=true   http://www.example.com/lib/exe/css.php?purge=true
 +
 ===== Two-Stage-Caching ===== ===== Two-Stage-Caching =====
  
Line 35: Line 39:
   * ''.code'' --- portions of the page between ''%%<code> ... </code>%%'' tags after highlighting has been applied.   * ''.code'' --- portions of the page between ''%%<code> ... </code>%%'' tags after highlighting has been applied.
  
-=====Metadata=====+===== Metadata =====
  
 DokuWiki can also store [[metadata]] e.g. additional information of pages. Metadata is generated from the Instruction Cache, of which the XHTML of a page is generated too. The metadata has its own [[metadata#metadata_and_caching|caching mechanism]]. DokuWiki can also store [[metadata]] e.g. additional information of pages. Metadata is generated from the Instruction Cache, of which the XHTML of a page is generated too. The metadata has its own [[metadata#metadata_and_caching|caching mechanism]].
Line 41: Line 45:
 Metadata can furthermore be added to the [[metadata#Metadata Index]]. Here is the added information searchable. Metadata can furthermore be added to the [[metadata#Metadata Index]]. Here is the added information searchable.
  
-=====Images=====+===== Images =====
 To improve the performance for the user, DokuWiki tries to cache external images. If someone wants to use an external image in the wiki content without caching or cache the image with a certain interval, there is [[:images#caching|syntax]] to  influence the caching behavior. To improve the performance for the user, DokuWiki tries to cache external images. If someone wants to use an external image in the wiki content without caching or cache the image with a certain interval, there is [[:images#caching|syntax]] to  influence the caching behavior.
  
Line 51: Line 55:
  
  
-==== developer note ====+==== Developer note ====
  
 A simple measure to avoid caching is that plugin developers turn off caching completely. This is discouraged due to the extra rendering activities, in particular adversely for high traffic wikis. Instead of the plugin developers make use of the functionality to influence the cache by checking (themself formulated) dependencies. Therefore a syntax plugin will need to: A simple measure to avoid caching is that plugin developers turn off caching completely. This is discouraged due to the extra rendering activities, in particular adversely for high traffic wikis. Instead of the plugin developers make use of the functionality to influence the cache by checking (themself formulated) dependencies. Therefore a syntax plugin will need to:
Line 57: Line 61:
   * add an [[action plugin]] component to handle the ''[[devel:event:parser_cache_use|PARSER_CACHE_USE]]'' event.   * add an [[action plugin]] component to handle the ''[[devel:event:parser_cache_use|PARSER_CACHE_USE]]'' event.
  
-Caching itself is handled by the cache object((''inc/cache.php'')). The key parts of that object of interest to plugins are:+Caching itself is handled by the Cache object((''inc/Cache/Cache.php'')). The key parts of that object of interest to plugins are:
   * the ''depends'' array --- DokuWiki fills this all the known dependencies of the page and then uses standard routines to process them. Plugins can add/modify these dependencies before they are processed. The different types of dependencies are:   * the ''depends'' array --- DokuWiki fills this all the known dependencies of the page and then uses standard routines to process them. Plugins can add/modify these dependencies before they are processed. The different types of dependencies are:
     * ''purge'' --- expire the cache     * ''purge'' --- expire the cache
     * ''age'' --- expire the cache if its older than age (affected by the metadata value 'date valid')     * ''age'' --- expire the cache if its older than age (affected by the metadata value 'date valid')
-    * ''files'' --- expire the cache if it is older than any of the files in this array.  Only local files may be added.  Take a look at ''[[xref>inc/cache.php]]'' for a list of the files.  Perhaps most interestingly the cached xhtml is dependent on the page's metadata. +    * ''files'' --- expire the cache if it is older than any of the files in this array.  Only local files may be added.  Take a look at ''[[xref>dokuwiki\Cache\Cache]]'' and it’s subclasses for a list of the files.  Perhaps most interestingly the cached xhtml is dependent on the page's metadata. 
-  * the cache name, ''cache'' --- a unique identifier under which the cache is stored.  Normally it is dependent on the page name, ''%%HTTP_HOST%%'' and the server port. Plugins can generate more complex identifiers, e.g. the [[:plugin:include]] generates identifiers using included page names and whether or not the current user has read access to those pages.+  * the cache name, ''cache'' --- a unique identifier under which the cache is stored.  Normally it is dependent on the page name, ''%%HTTP_HOST%%'' and the server port. Plugins can generate more complex identifiers, by extending the key with a certain identifier and recreate the cache name e.g. the [[:plugin:include]] generates identifiers using included page names and whether or not the current user has read access to those pages. 
  
 === Individual Page Cache Expiry === === Individual Page Cache Expiry ===
Line 69: Line 73:
 /* code to expire the cached xhtml of page ns:page /* code to expire the cached xhtml of page ns:page
  * $id = 'ns:page';  * $id = 'ns:page';
- * $data = array('cache' => 'expire');  // the metadata being added + * $data = array('cache' => 'expire'); // the metadata being added 
- * $render = false;                     // no need to re-render metadata now + * $render = false;     // no need to re-render metadata now 
- * $persistent = false;                 // this change doesn't need to persist passed the next metadata render.+ * $persistent = false; // this change doesn't need to persist passed 
 +                         the next metadata render.
  */  */
 p_set_metadata($id, $data, $render, $persistent); p_set_metadata($id, $data, $render, $persistent);
devel/caching.1638393013.txt.gz · Last modified: by andi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki