CINXE.COM

devel:caching [DokuWiki]

<!DOCTYPE html> <html lang="en" dir="ltr" class="no-js"> <head> <meta charset="utf-8" /> <title>devel:caching [DokuWiki]</title> <meta name="generator" content="DokuWiki"/> <meta name="theme-color" content="#008800"/> <meta name="robots" content="index,follow"/> <meta name="keywords" content="devel,caching"/> <link rel="search" type="application/opensearchdescription+xml" href="/lib/exe/opensearch.php" title="DokuWiki"/> <link rel="start" href="/"/> <link rel="contents" href="/devel:caching?do=index" title="Sitemap"/> <link rel="manifest" href="/lib/exe/manifest.php"/> <link rel="alternate" type="application/rss+xml" title="Recent Changes" href="/feed.php"/> <link rel="alternate" type="application/rss+xml" title="Current namespace" href="/feed.php?mode=list&amp;ns=devel"/> <link rel="edit" title="Edit this page" href="/devel:caching?do=edit"/> <link rel="alternate" type="text/html" title="Plain HTML" href="/_export/xhtml/devel:caching"/> <link rel="alternate" type="text/plain" title="Wiki Markup" href="/_export/raw/devel:caching"/> <link rel="canonical" href="https://www.dokuwiki.org/devel:caching"/> <link rel="stylesheet" href="/lib/exe/css.php?t=dokuwiki&amp;tseed=f1005bad3d81fc9c803c7f93d32a390e"/> <link rel="alternate" hreflang="ru" href="https://www.dokuwiki.org/ru:devel:caching"/> <link rel="alternate" hreflang="zh" href="https://www.dokuwiki.org/zh:devel:caching"/> <link rel="alternate" hreflang="x-default" href="https://www.dokuwiki.org/devel:caching"/> <script >var NS='devel';var JSINFO = {"plugins":{"edittable":{"default columnwidth":""}},"id":"devel:caching","namespace":"devel","ACT":"show","useHeadingNavigation":0,"useHeadingContent":0};(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js" defer="defer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js" defer="defer"></script> <script src="/lib/exe/js.php?t=dokuwiki&amp;tseed=f1005bad3d81fc9c803c7f93d32a390e&amp;lang=en" defer="defer"></script> <meta name="viewport" content="width=device-width,initial-scale=1" /> <link rel="shortcut icon" href="/lib/tpl/dokuwiki/images/favicon.ico" /> <link rel="apple-touch-icon" href="/lib/tpl/dokuwiki/images/apple-touch-icon.png" /> <meta name="verify-v1" content="OVxl3gsCv2MhZqh1cBQyl0JytWXSwXMjyvwc+4w3WtA=" /> <meta name="google-site-verification" content="YhTVK69hW94ZXUtc2zSLPxTkZKbZIn0zK67mz5WQB-E" /> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-83791-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-83791-1', { 'anonymize_ip': true }); </script> </head> <body> <div id="dokuwiki__site"><div id="dokuwiki__top" class="site dokuwiki mode_show tpl_dokuwiki showSidebar hasSidebar"> <!-- ********** HEADER ********** --> <header id="dokuwiki__header"><div class="pad group"> <div class="headings group"> <ul class="a11y skip"> <li><a href="#dokuwiki__content">skip to content</a></li> </ul> <h1 class="logo"><a href="/start" accesskey="h" title="Home [h]"><img src="/lib/tpl/dokuwiki/images/logo.png" width="64" height="64" alt="" /><span>DokuWiki</span></a></h1> <p class="claim">It's better when it's simple</p> </div> <div class="tools group"> <!-- USER TOOLS --> <div id="dokuwiki__usertools"> <h3 class="a11y">User Tools</h3> <ul> <li class="action login"><a href="/devel:caching?do=login&amp;sectok=" title="Log In" rel="nofollow"><span>Log In</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 17.25V14H3v-4h7V6.75L15.25 12 10 17.25M8 2h9a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2v-4h2v4h9V4H8v4H6V4a2 2 0 0 1 2-2z"/></svg></a></li> </ul> </div> <!-- SITE TOOLS --> <div id="dokuwiki__sitetools"> <h3 class="a11y">Site Tools</h3> <form action="/start" method="get" role="search" class="search doku_form" id="dw__search" accept-charset="utf-8"><input type="hidden" name="do" value="search" /><input type="hidden" name="id" value="devel:caching" /><div class="no"><input name="q" type="text" class="edit" title="[F]" accesskey="f" placeholder="Search" autocomplete="on" id="qsearch__in" value="" /><button value="1" type="submit" title="Search">Search</button><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form> <div class="mobileTools"> <form action="/doku.php" method="get" accept-charset="utf-8"><div class="no"><input type="hidden" name="id" value="devel:caching" /><select name="do" class="edit quickselect" title="Tools"><option value="">Tools</option><optgroup label="Page Tools"><option value="edit">Edit this page</option><option value="revisions">Old revisions</option><option value="backlink">Backlinks</option></optgroup><optgroup label="Site Tools"><option value="recent">Recent Changes</option><option value="media">Media Manager</option><option value="index">Sitemap</option></optgroup><optgroup label="User Tools"><option value="login">Log In</option></optgroup></select><button type="submit">&gt;</button></div></form> </div> <ul> <li class="action recent"><a href="/devel:caching?do=recent" title="Recent Changes [r]" rel="nofollow" accesskey="r">Recent Changes</a></li><li class="action media"><a href="/devel:caching?do=media&amp;ns=devel" title="Media Manager" rel="nofollow">Media Manager</a></li><li class="action index"><a href="/devel:caching?do=index" title="Sitemap [x]" rel="nofollow" accesskey="x">Sitemap</a></li> </ul> </div> </div> <!-- BREADCRUMBS --> <div class="breadcrumbs"> <div class="trace"><span class="bchead">Trace:</span> <span class="bcsep">•</span> <span class="curid"><bdi><a href="/devel:caching" class="breadcrumbs" title="devel:caching">caching</a></bdi></span></div> </div> <hr class="a11y" /> </div></header><!-- /header --> <div class="wrapper group"> <!-- ********** ASIDE ********** --> <nav id="dokuwiki__aside" aria-label="Sidebar"><div class="pad aside include group"> <h3 class="toggle">Sidebar</h3> <div class="content"><div class="group"> <div class="plugin_translation is-dropdown"><span class="title">Translations of this page<sup><a href="/localization" class="wikilink1" title="localization" data-wiki-id="localization">?</a></sup>: </span><ul><li class="span"><span class="wikilink1" title="English">English (en)</span></li><li class="a"><a class="wikilink2" title="|العربية" href="/ar:devel:caching">|العربية (ar)</a></li><li class="a"><a class="wikilink2" title="Català" href="/ca:devel:caching">Català (ca)</a></li><li class="a"><a class="wikilink2" title="Česky" href="/cs:devel:caching">Česky (cs)</a></li><li class="a"><a class="wikilink2" title="Dansk" href="/da:devel:caching">Dansk (da)</a></li><li class="a"><a class="wikilink2" title="Deutsch" href="/de:devel:caching">Deutsch (de)</a></li><li class="a"><a class="wikilink2" title="Ελληνικά" href="/el:devel:caching">Ελληνικά (el)</a></li><li class="a"><a class="wikilink2" title="Esperanto" href="/eo:devel:caching">Esperanto (eo)</a></li><li class="a"><a class="wikilink2" title="Español" href="/es:devel:caching">Español (es)</a></li><li class="a"><a class="wikilink2" title="فارسی" href="/fa:devel:caching">فارسی (fa)</a></li><li class="a"><a class="wikilink2" title="Français" href="/fr:devel:caching">Français (fr)</a></li><li class="a"><a class="wikilink2" title="עברית" href="/he:devel:caching">עברית (he)</a></li><li class="a"><a class="wikilink2" title="Magyar" href="/hu:devel:caching">Magyar (hu)</a></li><li class="a"><a class="wikilink2" title="Italiano" href="/it:devel:caching">Italiano (it)</a></li><li class="a"><a class="wikilink2" title="日本語" href="/ja:devel:caching">日本語 (ja)</a></li><li class="a"><a class="wikilink2" title="한국어" href="/ko:devel:caching">한국어 (ko)</a></li><li class="a"><a class="wikilink2" title="Lietuvių Kalba" href="/lt:devel:caching">Lietuvių Kalba (lt)</a></li><li class="a"><a class="wikilink2" title="Nederlands" href="/nl:devel:caching">Nederlands (nl)</a></li><li class="a"><a class="wikilink2" title="Norsk" href="/no:devel:caching">Norsk (no)</a></li><li class="a"><a class="wikilink2" title="Polski" href="/pl:devel:caching">Polski (pl)</a></li><li class="a"><a class="wikilink2" title="Português" href="/pt-br:devel:caching">Português (pt-br)</a></li><li class="a"><a class="wikilink2" title="Română" href="/ro:devel:caching">Română (ro)</a></li><li class="a"><a class="wikilink1" title="Русский" href="/ru:devel:caching">Русский (ru)</a></li><li class="a"><a class="wikilink2" title="Српски Језик" href="/sr:devel:caching">Српски Језик (sr)</a></li><li class="a"><a class="wikilink2" title="Svenska" href="/sv:devel:caching">Svenska (sv)</a></li><li class="a"><a class="wikilink2" title="ไทย" href="/th:devel:caching">ไทย (th)</a></li><li class="a"><a class="wikilink2" title="Українська" href="/uk:devel:caching">Українська (uk)</a></li><li class="a"><a class="wikilink1" title="中文" href="/zh:devel:caching">中文 (zh)</a></li><li class="a"><a class="wikilink2" title="繁體中文" href="/zh-tw:devel:caching">繁體中文 (zh-tw)</a></li></ul></div> <p> <strong>Learn about DokuWiki</strong> </p> <ul> <li class="level1"><div class="li"> <a href="/features" class="wikilink1" title="features" data-wiki-id="features">Features</a> &amp; <a href="/blogroll" class="wikilink1" title="blogroll" data-wiki-id="blogroll">reviews</a> </div> </li> <li class="level1"><div class="li"> <a href="/install" class="wikilink1" title="install" data-wiki-id="install">Installation guide</a></div> </li> <li class="level1"><div class="li"> <a href="/manual" class="wikilink1" title="manual" data-wiki-id="manual">User manual</a> &amp; <a href="/wiki:syntax" class="wikilink1" title="wiki:syntax" data-wiki-id="wiki:syntax">syntax</a></div> </li> <li class="level1"><div class="li"> <a href="/changes" class="wikilink1" title="changes" data-wiki-id="changes">Release notes</a></div> </li> <li class="level1"><div class="li"> <a href="/faq" class="wikilink1" title="faq" data-wiki-id="faq">FAQ</a></div> </li> </ul> <p> <strong>Advanced Use</strong> </p> <ul> <li class="level1"><div class="li"> <a href="/extensions" class="wikilink1" title="extensions" data-wiki-id="extensions">Extensions</a></div> </li> <li class="level1"><div class="li"> <a href="/development" class="wikilink1" title="development" data-wiki-id="development">Development manual</a></div> </li> </ul> <p> <strong>Corporate Use</strong> </p> <ul> <li class="level1"><div class="li"> <a href="/faq:support" class="wikilink1" title="faq:support" data-wiki-id="faq:support">Get support</a></div> </li> <li class="level1"><div class="li"> <a href="/donate" class="wikilink1" title="donate" data-wiki-id="donate">Donations</a></div> </li> </ul> <p> <strong>Our Community</strong> </p> <ul> <li class="level1"><div class="li"> <a href="/teams:getting_involved" class="wikilink1" title="teams:getting_involved" data-wiki-id="teams:getting_involved">Get involved</a></div> </li> <li class="level1"><div class="li"> <a href="/dokuinstall" class="wikilink1" title="dokuinstall" data-wiki-id="dokuinstall">Users</a></div> </li> <li class="level1"><div class="li"> <a href="http://forum.dokuwiki.org" class="urlextern" title="http://forum.dokuwiki.org">User forum</a></div> </li> <li class="level1"><div class="li"> <a href="/mailinglist" class="wikilink1" title="mailinglist" data-wiki-id="mailinglist">Development mailinglist</a></div> </li> </ul> <hr /> <p> Follow us on <a href="https://phpc.social/@dokuwiki" class="urlextern" title="https://phpc.social/@dokuwiki">Mastodon</a> and other <a href="/social" class="wikilink1" title="social" data-wiki-id="social">social networks</a>. </p> <p> <a href="/privacy" class="wikilink1" title="privacy" data-wiki-id="privacy">Our Privacy Policy</a> </p> </div></div> </div></nav><!-- /aside --> <!-- ********** CONTENT ********** --> <main id="dokuwiki__content"><div class="pad group"> <div class="pageId"><span>devel:caching</span></div> <div class="page group"> <!-- wikipage start --> <!-- TOC START --> <div id="dw__toc" class="dw__toc"> <h3 class="toggle">Table of Contents</h3> <div> <ul class="toc"> <li class="level1"><div class="li"><a href="#caching">Caching</a></div> <ul class="toc"> <li class="level2"><div class="li"><a href="#purging_the_cache">Purging the cache</a></div></li> <li class="level2"><div class="li"><a href="#two-stage-caching">Two-Stage-Caching</a></div> <ul class="toc"> <li class="level3"><div class="li"><a href="#location">Location</a></div></li> </ul> </li> <li class="level2"><div class="li"><a href="#metadata">Metadata</a></div></li> <li class="level2"><div class="li"><a href="#images">Images</a></div></li> <li class="level2"><div class="li"><a href="#plugins">Plugins</a></div> <ul class="toc"> <li class="level3"><div class="li"><a href="#developer_note">Developer note</a></div></li> </ul></li> </ul></li> </ul> </div> </div> <!-- TOC END --> <h1 class="sectionedit1" id="caching">Caching</h1> <div class="level1"> <p> <a href="/dokuwiki" class="wikilink1" title="dokuwiki" data-wiki-id="dokuwiki">DokuWiki</a> speeds up browsing through the wiki by caching parsed files. If a currently cached version of a document exists, this cached copy is delivered instead of parsing the data again. On editing and previewing no cache is used. </p> </div> <div class="secedit editbutton_section editbutton_1"><form class="button btn_secedit" method="post" action="/devel:caching"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1739259887" /><input type="hidden" name="summary" value="[Caching] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="caching" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="1-259" /><button type="submit" title="Caching">Edit</button></div></form></div> <h2 class="sectionedit2" id="purging_the_cache">Purging the cache</h2> <div class="level2"> <p> To force the recaching of a single page just add the parameter <code>purge</code> to the <abbr title="Uniform Resource Locator">URL</abbr>. Example: </p> <pre class="code">http://www.example.com/namespace/page?purge=true</pre> <p> Some of your <abbr title="Uniform Resource Locator">URL</abbr> might look like this <code>?id=pagename</code> then use <code>&amp;</code> between parameters. Note that order does not matter. Both examples below are valid and produce the same result: </p> <pre class="code">http://localhost/dokuwiki/doku.php?id=my_page_name&amp;purge=true http://localhost/dokuwiki/doku.php?purge=true&amp;id=my_page_name</pre> <p> To force recaching of all pages, including page instructions, <a href="http://man.cx/touch" class="interwiki iw_man" title="http://man.cx/touch">touch</a><sup><a href="#fn__1" id="fnt__1" class="fn_top">1)</a></sup> the local configuration file, <code>conf/local.php</code>. Saving the configuration settings form over the <a href="/plugin:config" class="wikilink1" title="plugin:config" data-wiki-id="plugin:config">admin interface</a> will have the same effect. </p> <p> <strong>Note:</strong> There is the <a href="/plugin:stale" class="wikilink1" title="plugin:stale" data-wiki-id="plugin:stale">stale plugin</a> providing a one-click-action for this purpose. </p> <p> To only force recaching of page xhtml, touch <code>inc/parser/xhtml.php</code>. </p> <p> To purge the editor toolbar (and other cached JavaScript) call </p> <pre class="code">http://www.example.com/lib/exe/js.php?purge=true</pre> <p> and clean up your browser&#039;s cache (Ctrl+F5) as well. This especially helps if a new button introduced by a plugin does not show up. </p> <p> You can also clear the <abbr title="Cascading Style Sheets">CSS</abbr> cache in the same way: </p> <pre class="code">http://www.example.com/lib/exe/css.php?purge=true</pre> </div> <div class="secedit editbutton_section editbutton_2"><form class="button btn_secedit" method="post" action="/devel:caching"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1739259887" /><input type="hidden" name="summary" value="[Purging the cache] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="purging_the_cache" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="260-1615" /><button type="submit" title="Purging the cache">Edit</button></div></form></div> <h2 class="sectionedit3" id="two-stage-caching">Two-Stage-Caching</h2> <div class="level2"> <p> 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. </p> <ul> <li class="level1"><div class="li"> <em class="u">Instruction Cache</em> <br/> The instruction cachefile only gets updated when the page, the config files<sup><a href="#fn__2" id="fnt__2" class="fn_top">2)</a></sup>, some of DokuWiki&#039;s PHP files<sup><a href="#fn__3" id="fnt__3" class="fn_top">3)</a></sup> are changed or plugins are added/removed/enabled/disabled using the <a href="/plugin:extension" class="wikilink1" title="plugin:extension" data-wiki-id="plugin:extension">Extension</a> manager.</div> </li> </ul> <ul> <li class="level1"><div class="li"> <em class="u">XHTML Cache</em> <br/> The XHTML cache is also affected by a maximum cache age setting (<a href="/config:cachetime" class="wikilink1" title="config:cachetime" data-wiki-id="config:cachetime">cachetime</a>), its metadata, some more php files<sup><a href="#fn__4" id="fnt__4" class="fn_top">4)</a></sup>, whenever the existence state of an internal link changes (i.e. the link target page is created or deleted) or when an <a href="/rss" class="wikilink1" title="rss" data-wiki-id="rss">RSS</a> feed needs refreshing.</div> </li> </ul> </div> <div class="secedit editbutton_section editbutton_3"><form class="button btn_secedit" method="post" action="/devel:caching"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1739259887" /><input type="hidden" name="summary" value="[Two-Stage-Caching] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="two-stage-caching" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="1616-2577" /><button type="submit" title="Two-Stage-Caching">Edit</button></div></form></div> <h3 class="sectionedit4" id="location">Location</h3> <div class="level3"> <p> The XHTML and instruction cache are located in <code>data/cache/*</code> <sup><a href="#fn__5" id="fnt__5" class="fn_top">5)</a></sup>. The files end in <code>.xhtml</code>, <code>.i</code>. Other files are also stored under the cache directory, including: </p> <ul> <li class="level1"><div class="li"> <code>.feed</code> — any rss feeds generated for the wiki</div> </li> <li class="level1"><div class="li"> <code>.code</code> — portions of the page between <code>&lt;code&gt; ... &lt;/code&gt;</code> tags after highlighting has been applied.</div> </li> </ul> </div> <div class="secedit editbutton_section editbutton_4"><form class="button btn_secedit" method="post" action="/devel:caching"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1739259887" /><input type="hidden" name="summary" value="[Location] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="location" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="2578-3039" /><button type="submit" title="Location">Edit</button></div></form></div> <h2 class="sectionedit5" id="metadata">Metadata</h2> <div class="level2"> <p> DokuWiki can also store <a href="/devel:metadata" class="wikilink1" title="devel:metadata" data-wiki-id="devel:metadata">metadata</a> 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 <a href="/devel:metadata#metadata_and_caching" class="wikilink1" title="devel:metadata" data-wiki-id="devel:metadata">caching mechanism</a>. </p> <p> Metadata can furthermore be added to the <a href="/devel:metadata#metadata_index" class="wikilink1" title="devel:metadata" data-wiki-id="devel:metadata">Metadata Index</a>. Here is the added information searchable. </p> </div> <div class="secedit editbutton_section editbutton_5"><form class="button btn_secedit" method="post" action="/devel:caching"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1739259887" /><input type="hidden" name="summary" value="[Metadata] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="metadata" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="3040-3425" /><button type="submit" title="Metadata">Edit</button></div></form></div> <h2 class="sectionedit6" id="images">Images</h2> <div class="level2"> <p> 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 <a href="/images#caching" class="wikilink1" title="images" data-wiki-id="images">syntax</a> to influence the caching behavior. </p> <p> <img src="/lib/images/smileys/fixme.svg" class="icon smiley" alt="FIXME" /> howto link (external) images in plugins with caching. </p> </div> <div class="secedit editbutton_section editbutton_6"><form class="button btn_secedit" method="post" action="/devel:caching"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1739259887" /><input type="hidden" name="summary" value="[Images] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="images" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="3426-3782" /><button type="submit" title="Images">Edit</button></div></form></div> <h2 class="sectionedit7" id="plugins">Plugins</h2> <div class="level2"> <p> <a href="/plugins" class="wikilink1" title="plugins" data-wiki-id="plugins">Plugins</a> can influence cache use via the <code><a href="/devel:event:parser_cache_use" class="wikilink1" title="devel:event:parser_cache_use" data-wiki-id="devel:event:parser_cache_use">PARSER_CACHE_USE</a></code> 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&#039;t normally. </p> </div> <div class="secedit editbutton_section editbutton_7"><form class="button btn_secedit" method="post" action="/devel:caching"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1739259887" /><input type="hidden" name="summary" value="[Plugins] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="plugins" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="3783-4087" /><button type="submit" title="Plugins">Edit</button></div></form></div> <h3 class="sectionedit8" id="developer_note">Developer note</h3> <div class="level3"> <p> 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: </p> <ul> <li class="level1"><div class="li"> save some information relating to the pages it&#039;s involved with and the dependency specific to each of those pages. The page&#039;s <a href="/metadata" class="wikilink1" title="metadata" data-wiki-id="metadata">metadata</a> is a useful place for this. Metadata can be accessed via <code>$INFO[&#039;metadata&#039;]</code> and the <code>p_get_metadata()</code> and <code>p_set_metadata()</code> functions. If using metadata please try to stick to <a href="http://dublincore.org" class="urlextern" title="http://dublincore.org">Dublin Core Metadata standards</a>.</div> </li> <li class="level1"><div class="li"> add an <a href="/devel:action_plugins" class="wikilink1" title="devel:action_plugins" data-wiki-id="devel:action_plugins">action plugin</a> component to handle the <code><a href="/devel:event:parser_cache_use" class="wikilink1" title="devel:event:parser_cache_use" data-wiki-id="devel:event:parser_cache_use">PARSER_CACHE_USE</a></code> event.</div> </li> </ul> <p> Caching itself is handled by the Cache object<sup><a href="#fn__6" id="fnt__6" class="fn_top">6)</a></sup>. The key parts of that object of interest to plugins are: </p> <ul> <li class="level1 node"><div class="li"> the <code>depends</code> 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:</div> <ul> <li class="level2"><div class="li"> <code>purge</code> — expire the cache</div> </li> <li class="level2"><div class="li"> <code>age</code> — expire the cache if its older than age (affected by the metadata value &#039;date valid&#039;)</div> </li> <li class="level2"><div class="li"> <code>files</code> — 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 <code><a href="https://codesearch.dokuwiki.org/search?project=dokuwiki&amp;defs=Cache&amp;path=inc%20Cache%20Cache" class="interwiki plugin_xref" title="view definition for dokuwiki\Cache\Cache">dokuwiki\Cache\Cache</a></code> and it’s subclasses for a list of the files. Perhaps most interestingly the cached xhtml is dependent on the page&#039;s metadata.</div> </li> </ul> </li> <li class="level1"><div class="li"> the cache name, <code>cache</code> — a unique identifier under which the cache is stored. Normally it is dependent on the page name, <code>HTTP_HOST</code> 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 <a href="/plugin:include" class="wikilink1" title="plugin:include" data-wiki-id="plugin:include">include</a> generates identifiers using included page names and whether or not the current user has read access to those pages. </div> </li> </ul> </div> <h4 id="individual_page_cache_expiry">Individual Page Cache Expiry</h4> <div class="level4"> <p> As described above, DokuWiki verifies the validity of the cache rather than actively expiring the cache. However, the page xhtml is dependent on its metadata. That is, if the metadata file is more recent than the cache, DokuWiki will determine that the cache is invalid and re-render the page. So, we can update the metadata to expire the cache. </p> <pre class="code php"><span class="coMULTI">/* code to expire the cached xhtml of page ns:page * $id = 'ns:page'; * $data = array('cache' =&gt; 'expire'); // the metadata being added * $render = false; // no need to re-render metadata now * $persistent = false; // this change doesn't need to persist passed * the next metadata render. */</span> p_set_metadata<span class="br0">&#40;</span><span class="re0">$id</span><span class="sy0">,</span> <span class="re0">$data</span><span class="sy0">,</span> <span class="re0">$render</span><span class="sy0">,</span> <span class="re0">$persistent</span><span class="br0">&#41;</span><span class="sy0">;</span></pre> </div> <div class="secedit editbutton_section editbutton_8"><form class="button btn_secedit" method="post" action="/devel:caching"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1739259887" /><input type="hidden" name="summary" value="[Developer note] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="developer_note" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="4088-" /><button type="submit" title="Developer note">Edit</button></div></form></div><div class="footnotes"> <div class="fn"><sup><a href="#fnt__1" id="fn__1" class="fn_bot">1)</a></sup> <div class="content">Non-Unix users can simply open the file and save it again – the idea is to change the file&#039;s timestamp</div></div> <div class="fn"><sup><a href="#fnt__2" id="fn__2" class="fn_bot">2)</a></sup> <div class="content"><code>conf/dokuwiki.php</code> &amp; <code>conf/local.php</code></div></div> <div class="fn"><sup><a href="#fnt__3" id="fn__3" class="fn_bot">3)</a></sup> <div class="content"><code>inc/parser/parser.php</code> &amp; <code>inc/parser/handler.php</code></div></div> <div class="fn"><sup><a href="#fnt__4" id="fn__4" class="fn_bot">4)</a></sup> <div class="content"><code>inc/parser/xhtml</code> &amp; <code>inc/parser/metadata</code></div></div> <div class="fn"><sup><a href="#fnt__5" id="fn__5" class="fn_bot">5)</a></sup> <div class="content">* being a single character directory name, <br/> <code>data</code> being configurable by <a href="/config:savedir" class="wikilink1" title="config:savedir" data-wiki-id="config:savedir">savedir</a></div></div> <div class="fn"><sup><a href="#fnt__6" id="fn__6" class="fn_bot">6)</a></sup> <div class="content"><code>inc/Cache/Cache.php</code></div></div> </div> <!-- wikipage stop --> </div> <div class="docInfo"><bdi>devel/caching.txt</bdi> · Last modified: <time datetime="2025-02-11T08:44:47+0100">2025-02-11 08:44</time> by <bdi>217.175.54.43</bdi></div> <hr class="a11y" /> </div></main><!-- /content --> <!-- PAGE ACTIONS --> <nav id="dokuwiki__pagetools" aria-labelledby="dokuwiki__pagetools__heading"> <h3 class="a11y" id="dokuwiki__pagetools__heading">Page Tools</h3> <div class="tools"> <ul> <li class="edit"><a href="/devel:caching?do=edit" title="Edit this page [e]" rel="nofollow" accesskey="e"><span>Edit this page</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"/></svg></a></li><li class="revs"><a href="/devel:caching?do=revisions" title="Old revisions [o]" rel="nofollow" accesskey="o"><span>Old revisions</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M11 7v5.11l4.71 2.79.79-1.28-4-2.37V7m0-5C8.97 2 5.91 3.92 4.27 6.77L2 4.5V11h6.5L5.75 8.25C6.96 5.73 9.5 4 12.5 4a7.5 7.5 0 0 1 7.5 7.5 7.5 7.5 0 0 1-7.5 7.5c-3.27 0-6.03-2.09-7.06-5h-2.1c1.1 4.03 4.77 7 9.16 7 5.24 0 9.5-4.25 9.5-9.5A9.5 9.5 0 0 0 12.5 2z"/></svg></a></li><li class="backlink"><a href="/devel:caching?do=backlink" title="Backlinks" rel="nofollow"><span>Backlinks</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10.59 13.41c.41.39.41 1.03 0 1.42-.39.39-1.03.39-1.42 0a5.003 5.003 0 0 1 0-7.07l3.54-3.54a5.003 5.003 0 0 1 7.07 0 5.003 5.003 0 0 1 0 7.07l-1.49 1.49c.01-.82-.12-1.64-.4-2.42l.47-.48a2.982 2.982 0 0 0 0-4.24 2.982 2.982 0 0 0-4.24 0l-3.53 3.53a2.982 2.982 0 0 0 0 4.24m2.82-4.24c.39-.39 1.03-.39 1.42 0a5.003 5.003 0 0 1 0 7.07l-3.54 3.54a5.003 5.003 0 0 1-7.07 0 5.003 5.003 0 0 1 0-7.07l1.49-1.49c-.01.82.12 1.64.4 2.43l-.47.47a2.982 2.982 0 0 0 0 4.24 2.982 2.982 0 0 0 4.24 0l3.53-3.53a2.982 2.982 0 0 0 0-4.24.973.973 0 0 1 0-1.42z"/></svg></a></li><li class="top"><a href="#dokuwiki__top" title="Back to top [t]" rel="nofollow" accesskey="t"><span>Back to top</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"/></svg></a></li> </ul> </div> </nav> </div><!-- /wrapper --> <!-- ********** FOOTER ********** --> <footer id="dokuwiki__footer"><div class="pad"> <div class="license">Except where otherwise noted, content on this wiki is licensed under the following license: <bdi><a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en" rel="license" class="urlextern">CC Attribution-Share Alike 4.0 International</a></bdi></div> <div class="buttons"> <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en" rel="license"><img src="/lib/images/license/button/cc-by-sa.png" alt="CC Attribution-Share Alike 4.0 International" /></a> <a href="https://www.dokuwiki.org/donate" title="Donate" ><img src="/lib/tpl/dokuwiki/images/button-donate.gif" width="80" height="15" alt="Donate" /></a> <a href="https://php.net" title="Powered by PHP" ><img src="/lib/tpl/dokuwiki/images/button-php.gif" width="80" height="15" alt="Powered by PHP" /></a> <a href="//validator.w3.org/check/referer" title="Valid HTML5" ><img src="/lib/tpl/dokuwiki/images/button-html5.png" width="80" height="15" alt="Valid HTML5" /></a> <a href="//jigsaw.w3.org/css-validator/check/referer?profile=css3" title="Valid CSS" ><img src="/lib/tpl/dokuwiki/images/button-css.png" width="80" height="15" alt="Valid CSS" /></a> <a href="https://dokuwiki.org/" title="Driven by DokuWiki" ><img src="/lib/tpl/dokuwiki/images/button-dw.png" width="80" height="15" alt="Driven by DokuWiki" /></a> </div> <div style="margin-top: 2em; font-size:90%" class="dokuwiki"><div style="float:right"><a href="http://www.splitbrain.org/personal#imprint" style="float:right; text-decoration: none; color:#333">Imprint</a></div></div><!-- Include for DokuWiki site wide top bar --> <style type="text/css"> @media screen { body { padding-top: 30px; } #global__header { position: absolute; top: 0; left: 0; text-align: left; vertical-align: middle; line-height: 1.5; background-color: #333; box-shadow: 0 0 8px rgba(0,0,0,0.5); width: 100%; margin: 0; padding: 5px 20px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; white-space: nowrap; overflow: hidden; } #global__header h2 { position: absolute; left: -99999em; top: 0; overflow: hidden; display: inline; } #global__header ul, #global__header li { margin: 0; padding: 0; list-style: none; display: inline; line-height: 1.5; } #global__header a { color: #bbb; text-decoration: none; margin-right: 20px; font-size: 14px; font-weight: normal; } #global__header a:hover, #global__header a:active, #global__header a:focus { color: #fff; text-decoration: underline; } #global__header form { float: right; margin: 0 0 0 20px; } #global__header input { background-color: #333; background-image: none; border: 1px solid #bbb; color: #fff; box-shadow: none; border-radius: 2px; margin: 0; line-height: normal; padding: 1px 0 1px 0; height: auto; } #global__header input.button { border: none; color: #bbb; } #global__header input.button:hover, #global__header input.button:active, #global__header input.button:focus { color: #fff; text-decoration: underline; } } /* /@media */ @media only screen and (min-width: 601px) { /* changes specific for www.dokuwiki.org */ #dokuwiki__header { padding-top: 3em; } #dokuwiki__usertools { top: 3em; } /* changes specific for bugs.dokuwiki.org */ div#container div#showtask { top: 40px; } } /* /@media */ @media only screen and (max-width: 600px) { body { padding-top: 0; } #global__header { position: static; white-space: normal; overflow: auto; } #global__header form { float: none; display: block; margin: 0 0 .4em; } } /* /@media */ @media print { #global__header { display: none; } } /* /@media */ </style> <div id="global__header"> <h2>Global DokuWiki Links</h2> <form method="get" action="https://search.dokuwiki.org/" target="_top"> <input type="text" name="q" title="Search all DokuWiki sites at once" class="input" /> <input type="submit" title="Search all DokuWiki sites at once" value="Search" class="button" /> </form> <ul> <li><a href="https://download.dokuwiki.org" title="Download the latest release" target="_top">Download</a></li> <li><a href="https://www.dokuwiki.org" title="Read the DokuWiki documentation" target="_top">Wiki</a></li> <li><a href="https://forum.dokuwiki.org" title="Ask questions in the DokuWiki forum" target="_top">Forum</a></li> <li><a href="https://irc.dokuwiki.org" title="Check IRC chat logs or join the chat" target="_top">IRC</a></li> <li><a href="https://github.com/splitbrain/dokuwiki/issues" title="Report and track bugs" target="_top">Bugs</a></li> <li><a href="https://translate.dokuwiki.org/" title="Help translating the DokuWiki interface" target="_top">Translate</a></li> <li><a href="https://github.com/splitbrain/dokuwiki" title="Access the most recent git commits" target="_top">Git</a></li> <li><a href="https://xref.dokuwiki.org/reference/dokuwiki/" title="Cross-Reference of the DokuWiki source code" target="_top">XRef</a></li> <li><a href="https://codesearch.dokuwiki.org/" title="Search through the sources of DokuWiki, plugins and templates" target="_top">Code Search</a></li> </ul> </div> <!-- end of DokuWiki top bar include --> </div></footer><!-- /footer --> </div></div><!-- /site --> <div class="no"><img src="/lib/exe/taskrunner.php?id=devel%3Acaching&amp;1742665946" width="2" height="1" alt="" /></div> <div id="screen__mode" class="no"></div></body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10