DokuWiki

It's better when it's simple

用户工具

站点工具


侧边栏

翻译跟原始页面比较起来显得有些陈旧,所以可能失效。 查看更新
本页面的其他翻译?:

了解DokuWiki

进阶使用

商用

我们的社区


Facebook, Twitter 或其他社交网络上关注我们.

zh:devel:caching

currently translating FIXME

缓存

DokuWiki 通过缓存解析过的文件1)来加快浏览速度。如果一个当前缓存的文件版本已经存在,这个缓存的拷贝会直接发送到客户端,而不会重新解析数据。编辑和预览时不会用到缓存。

清理缓存

要强制重新缓存一个单独的页面,只要在 URL 中添加 purge 参数。例如:

http://www.example.com/namespace/page?purge=true

要强制重新缓存所有的页面,包括页面指令,可以执行 touch 2) 命令重新生成本地配置文件,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 files3), some of DokuWiki's PHP files4) are changed or plugins are added/removed/enabled/disabled using the plugin manager.
  • XHTML Cache
    The XHTML cache is also affected by a maximum cache age setting (cachetime), its metadata, some more php files5), 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/* 路径下 6)。文件名以 .xhtml.i 结尾。其它文件也会保存了这个缓存目录下,包括:

  • .feed — 为 wiki 生成的所有的 rss 源
  • .code — 启用高亮后,页面中 <code> ... </code> 标签之间的部分

插件

Plugins can now influence cache use via the 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 discussion & 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 Dublin Core Metadata standards.
  • add an action_plugin component to handle the PARSER_CACHE_USE event.

Caching itself is handled by the cache object7). 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 include generates identifiers using included page names and whether or not the current user has read access to those pages.
1)
图像缓存请参见 images
2)
非 Unix 用户可以简单地打开文件并重新保存 – 这么做是为了更新文件的时间戳
3)
conf/dokuwiki.php & conf/local.php
4)
inc/parser/parser.php & inc/parser/handler.php
5)
inc/parser/xhtml & inc/parser/metadata
6)
* 以单个字符为目录名,
data 是在 savedir 中设置的目录
7)
inc/cache.php
zh/devel/caching.txt · 最后更改: 2011-03-18 05:39 由 207.65.119.239