//currently translating// FIXME ====== 缓存 ====== [[:DokuWiki]] 通过缓存解析过的文件((图像缓存请参见 [[:images]] ))来加快浏览速度。如果一个当前缓存的文件版本已经存在,这个缓存的拷贝会直接发送到客户端,而不会重新解析数据。编辑和预览时不会用到缓存。 ===== 清理缓存 ===== 要强制重新缓存一个单独的页面,只要在 URL 中添加 ''purge'' 参数。例如: http://www.example.com/namespace/page?purge=true 要强制重新缓存所有的页面,包括页面指令,可以执行 [[man>touch]] ((非 Unix 用户可以简单地打开文件并重新保存 -- 这么做是为了更新文件的时间戳)) 命令重新生成本地配置文件,''conf/local.php''。 要强制重新缓存 xhtml 文件,执行 touch ''inc/parser/xhtml.php''。 ===== 两级缓存 ===== DokuWiki uses two cache files per page. To understand this you need to know that a page is parsed to an intermediate instruction format first before it is rendered to XHTML. DokuWiki caches both -- the instructions and the rendered XHTML. * __Instruction Cache__ \\ The instruction cachefile only gets updated when the page, the config files((''conf/dokuwiki.php'' & ''conf/local.php'')), some of DokuWiki's PHP files((''inc/parser/parser.php'' & ''inc/parser/handler.php'')) are changed or plugins are added/removed/enabled/disabled using the [[:plugin:extension]] manager. * __%%XHTML%% Cache__ \\ The XHTML cache is also affected by a maximum cache age setting ([[:config:cachetime]]), its metadata, some more php files((''inc/parser/xhtml'' & ''inc/parser/metadata'')), whenever the existence state of an internal link changes (i.e. the link target page is created or deleted) or when an [[:RSS]] feed needs refreshing. ==== 位置 ==== XHTML 和 指令缓存在 ''data/cache/*'' 路径下 ((* 以单个字符为目录名,\\ ''data'' 是在 [[:config:savedir]] 中设置的目录))。文件名以 ''.xhtml'',''.i'' 结尾。其它文件也会保存了这个缓存目录下,包括: * ''.feed'' --- 为 wiki 生成的所有的 rss 源 * ''.code'' --- 启用高亮后,页面中 ''%% ... %%'' 标签之间的部分 ===== 插件 ===== [[:Plugins]] can now influence cache use via the ''[[devel:event:parser_cache_use|PARSER_CACHE_USE]]'' event. This allows plugins which introduce additional dependencies for specific pages to check those dependencies and force DokuWiki to refresh the page when it wouldn't normally. ==== 开发者说明 ==== Up until now plugin developers have only been able to turn off caching completely. This has been necessary for plugins like [[:plugin:discussion]] & [[:plugin:include]]. To make use of the new functionality a syntax plugin will need to: * save some information relating to the pages its involved with and the dependency specific to each of those pages. The page's [[:metadata]] is a useful place for this. Metadata can be accessed via ''$INFO['metadata']'' and the ''p_get_metadata()'' and ''p_set_metadata()'' functions. If using metadata please try to stick to [[http://dublincore.org|Dublin Core Metadata standards]]. * 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: * 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 * ''age'' --- expire the cache if its older than age * ''files'' --- expire the cache if it is older than any of the files in this array. Only local files may be added. * 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.