Zend_Cache-Backends.xml 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 20756 -->
  4. <sect1 id="zend.cache.backends">
  5. <title><classname>Zend_Cache</classname> のバックエンド</title>
  6. <para>
  7. バックエンドには、標準と拡張の 2 種類があります。
  8. もちろん、拡張バックエンドのほうがより高機能となります。
  9. </para>
  10. <sect2 id="zend.cache.backends.file">
  11. <title>Zend_Cache_Backend_File</title>
  12. <para>
  13. この (拡張) バックエンドは、キャッシュレコードを
  14. (指定したディレクトリの) ファイルに保存します。
  15. </para>
  16. <para>
  17. 使用可能なオプションは次のとおりです。
  18. </para>
  19. <table id="zend.cache.backends.file.table">
  20. <title>File バックエンドのオプション</title>
  21. <tgroup cols="4">
  22. <thead>
  23. <row>
  24. <entry>オプション</entry>
  25. <entry>データ型</entry>
  26. <entry>デフォルト値</entry>
  27. <entry>説明</entry>
  28. </row>
  29. </thead>
  30. <tbody>
  31. <row>
  32. <entry><emphasis>cache_dir</emphasis></entry>
  33. <entry><type>String</type></entry>
  34. <entry>'<filename>/tmp/</filename>'</entry>
  35. <entry>
  36. キャッシュファイルを書き込むディレクトリ。
  37. </entry>
  38. </row>
  39. <row>
  40. <entry><emphasis>file_locking</emphasis></entry>
  41. <entry><type>Boolean</type></entry>
  42. <entry><constant>TRUE</constant></entry>
  43. <entry>
  44. ファイルロックを有効/無効にします。
  45. 不慮の事故でキャッシュが破壊されることを防げますが、
  46. マルチスレッドなウェブサーバ環境や <acronym>NFS</acronym> ファイルシステム上では役に立ちません。
  47. </entry>
  48. </row>
  49. <row>
  50. <entry><emphasis>read_control</emphasis></entry>
  51. <entry><type>Boolean</type></entry>
  52. <entry><constant>TRUE</constant></entry>
  53. <entry>
  54. 読み込み制御を有効/無効にします。有効にすると
  55. キャッシュファイルに制御キーが埋め込まれます。
  56. キャッシュの読み込み後、計算した結果とキャッシュのキーを比較します。
  57. </entry>
  58. </row>
  59. <row>
  60. <entry><emphasis>read_control_type</emphasis></entry>
  61. <entry><type>String</type></entry>
  62. <entry>'crc32'</entry>
  63. <entry>
  64. 読み込み制御の方式 (読み込み制御が有効な場合にのみ使用します)。
  65. 使用可能な値は
  66. 'md5' (一番安全だが、最も遅い)、
  67. 'crc32' (安全性には劣るが、より高速。悪くない選択肢です)、
  68. 'adler32' (新たな選択肢。crc32 より高速です)、
  69. 'strlen' (最も高速。長さのみをチェックします)
  70. のいずれかです。
  71. </entry>
  72. </row>
  73. <row>
  74. <entry><emphasis>hashed_directory_level</emphasis></entry>
  75. <entry><type>Integer</type></entry>
  76. <entry>0</entry>
  77. <entry>
  78. ディレクトリ構造のレベルを指定します。0 は "ディレクトリ階層を作らない"、
  79. 1 は "一段階のサブディレクトリを作る"、2 は "二段階の……" を意味します。
  80. 何千ものキャッシュファイルを使用する場合にのみ、
  81. このオプションによる高速化を実感できるでしょう。
  82. 適切な設定値を決めるには、実際にベンチマークを取得するしかありません。
  83. たいていの場合は 1 または 2 でよいでしょう。
  84. </entry>
  85. </row>
  86. <row>
  87. <entry><emphasis>hashed_directory_umask</emphasis></entry>
  88. <entry><type>Integer</type></entry>
  89. <entry>0700</entry>
  90. <entry>
  91. ディレクトリ構造の umask を指定します。
  92. </entry>
  93. </row>
  94. <row>
  95. <entry><emphasis>file_name_prefix</emphasis></entry>
  96. <entry><type>String</type></entry>
  97. <entry>'zend_cache'</entry>
  98. <entry>
  99. キャッシュファイルのプレフィックスを設定します。
  100. このオプションを設定する際には十分注意しましょう。
  101. あまりにもありふれた値をシステムのキャッシュディレクトリ
  102. (<filename>/tmp</filename> など) で使用すると、
  103. キャッシュの削除の際に余計なものまで削除されてしまうはめになります。
  104. </entry>
  105. </row>
  106. <row>
  107. <entry><emphasis>cache_file_umask</emphasis></entry>
  108. <entry><type>Integer</type></entry>
  109. <entry>0700</entry>
  110. <entry>
  111. キャッシュファイルの umask を設定します。
  112. </entry>
  113. </row>
  114. <row>
  115. <entry><emphasis>metatadatas_array_max_size</emphasis></entry>
  116. <entry><type>Integer</type></entry>
  117. <entry>100</entry>
  118. <entry>
  119. メタデータ配列の内部最大サイズを設定します
  120. (よくわからない場合はこの値を変更してはいけません)。
  121. </entry>
  122. </row>
  123. </tbody>
  124. </tgroup>
  125. </table>
  126. </sect2>
  127. <sect2 id="zend.cache.backends.sqlite">
  128. <title>Zend_Cache_Backend_Sqlite</title>
  129. <para>
  130. この (拡張) バックエンドは、キャッシュレコードを
  131. SQLite データベースに保存します。
  132. </para>
  133. <para>
  134. 使用可能なオプションは次のとおりです。
  135. </para>
  136. <table id="zend.cache.backends.sqlite.table">
  137. <title>Sqlite バックエンドのオプション</title>
  138. <tgroup cols="4">
  139. <thead>
  140. <row>
  141. <entry>オプション</entry>
  142. <entry>データ型</entry>
  143. <entry>デフォルト値</entry>
  144. <entry>説明</entry>
  145. </row>
  146. </thead>
  147. <tbody>
  148. <row>
  149. <entry><emphasis>cache_db_complete_path (必須)</emphasis></entry>
  150. <entry><type>String</type></entry>
  151. <entry><constant>NULL</constant></entry>
  152. <entry>
  153. SQLite データベースへの (ファイル名も含めた) フルパス。
  154. </entry>
  155. </row>
  156. <row>
  157. <entry><emphasis>automatic_vacuum_factor</emphasis></entry>
  158. <entry><type>Integer</type></entry>
  159. <entry>10</entry>
  160. <entry>
  161. 自動バキューム処理の設定を行います。
  162. 自動バキューム処理とは、<methodname>clean()</methodname> や <methodname>delete()</methodname>
  163. がコールされた際に自動的にデータベースの断片化解消を行う
  164. (そしてサイズを縮小する) ことです。
  165. 0 を指定すると、自動バキュームを行いません。
  166. 1 を指定すると (<methodname>delete()</methodname> や <methodname>clean()</methodname>
  167. がコールされると) そのたびにバキュームを行います。
  168. x (1 より大きな整数) を指定すると、
  169. <methodname>clean()</methodname> や <methodname>delete()</methodname> が x 回コールされるたびに
  170. 一回の頻度でランダムに自動バキュームを行います。
  171. </entry>
  172. </row>
  173. </tbody>
  174. </tgroup>
  175. </table>
  176. </sect2>
  177. <sect2 id="zend.cache.backends.memcached">
  178. <title>Zend_Cache_Backend_Memcached</title>
  179. <para>
  180. この (拡張) バックエンドは、キャッシュレコードを memcached サーバに保存します。
  181. <ulink url="http://www.danga.com/memcached/">memcached</ulink> は、
  182. 高性能な分散メモリオブジェクトキャッシュシステムです。このバックエンドを使用するには、
  183. memcached デーモンおよび
  184. <ulink url="http://pecl.php.net/package/memcache">memcache <acronym>PECL</acronym> 拡張モジュール</ulink>
  185. が必要です。
  186. </para>
  187. <para>
  188. 注意: このバックエンドでは、今のところ "タグ" がサポートされていません。
  189. また、引数 "doNotTestCacheValidity=true" もサポートされていません。
  190. </para>
  191. <para>
  192. 使用可能なオプションは次のとおりです。
  193. </para>
  194. <table id="zend.cache.backends.memcached.table">
  195. <title>Memcached バックエンドのオプション</title>
  196. <tgroup cols="4">
  197. <thead>
  198. <row>
  199. <entry>オプション</entry>
  200. <entry>データ型</entry>
  201. <entry>デフォルト値</entry>
  202. <entry>説明</entry>
  203. </row>
  204. </thead>
  205. <tbody>
  206. <row>
  207. <entry><emphasis>servers</emphasis></entry>
  208. <entry><type>Array</type></entry>
  209. <entry>
  210. <command>array(array('host' => 'localhost', 'port' => 11211,
  211. 'persistent' => true, 'weight' => 1, 'timeout' => 5,
  212. 'retry_interval' => 15, 'status' => true,
  213. 'failure_callback' => '' ))</command>
  214. </entry>
  215. <entry>
  216. memcached サーバの配列です。各 memcached サーバの情報は、
  217. 以下のような連想配列で指定します。
  218. 'host' => (string) : memcached サーバのサーバ名
  219. 'port' => (int) : memcached サーバのポート番号
  220. 'persistent' => (bool) : この memcached サーバに対して持続的な接続を使用するかどうか
  221. 'weight' => (int) : memcached サーバの重み付け
  222. 'timeout' => (int) : memcached サーバのタイムアウト
  223. 'retry_interval' => (int) : memcached サーバの再試行間隔
  224. 'status' => (bool) : memcached サーバのステータス
  225. 'failure_callback' => (callback) : memcached サーバのコールバック関数
  226. </entry>
  227. </row>
  228. <row>
  229. <entry><emphasis>compression</emphasis></entry>
  230. <entry><type>Boolean</type></entry>
  231. <entry><constant>FALSE</constant></entry>
  232. <entry>
  233. その場での圧縮処理を行いたい場合に <constant>TRUE</constant> を指定します。
  234. </entry>
  235. </row>
  236. <row>
  237. <entry><emphasis>compatibility</emphasis></entry>
  238. <entry><type>Boolean</type></entry>
  239. <entry><constant>FALSE</constant></entry>
  240. <entry>
  241. 古い memcache サーバ/拡張モジュールとの互換性モードを使用したい場合に
  242. <constant>TRUE</constant> を指定します。
  243. </entry>
  244. </row>
  245. </tbody>
  246. </tgroup>
  247. </table>
  248. </sect2>
  249. <sect2 id="zend.cache.backends.apc">
  250. <title>Zend_Cache_Backend_Apc</title>
  251. <para>
  252. この (拡張) バックエンドは、キャッシュレコードを共有メモリに保存する際に
  253. <ulink url="http://pecl.php.net/package/APC">APC</ulink> (Alternative <acronym>PHP</acronym> Cache)
  254. 拡張モジュールを使用します
  255. (当然、このバックエンドを使用するにはこの拡張モジュールが必要です)。
  256. </para>
  257. <para>
  258. 注意: このバックエンドでは、今のところ "タグ" がサポートされていません。
  259. また、引数 "doNotTestCacheValidity=true" もサポートされていません。
  260. </para>
  261. <para>
  262. このバックエンドではオプションを使用しません。
  263. </para>
  264. </sect2>
  265. <sect2 id="zend.cache.backends.xcache">
  266. <title>Zend_Cache_Backend_Xcache</title>
  267. <para>
  268. このバックエンドは、キャッシュレコードを共有メモリに保存する際に
  269. <ulink url="http://xcache.lighttpd.net/">XCache</ulink>
  270. 拡張モジュールを使用します
  271. (当然、このバックエンドを使うにはこの拡張モジュールが必要となります)。
  272. </para>
  273. <para>
  274. 注意: このバックエンドでは、今のところ "タグ" がサポートされていません。
  275. また、引数 "doNotTestCacheValidity=true" もサポートされていません。
  276. </para>
  277. <para>
  278. 使用可能なオプションは次のとおりです。
  279. </para>
  280. <table id="zend.cache.backends.xcache.table">
  281. <title>Xcache バックエンドのオプション</title>
  282. <tgroup cols="4">
  283. <thead>
  284. <row>
  285. <entry>オプション</entry>
  286. <entry>データ型</entry>
  287. <entry>デフォルト値</entry>
  288. <entry>説明</entry>
  289. </row>
  290. </thead>
  291. <tbody>
  292. <row>
  293. <entry><emphasis>user</emphasis></entry>
  294. <entry><type>String</type></entry>
  295. <entry><constant>NULL</constant></entry>
  296. <entry>
  297. <filename>xcache.admin.user</filename> です。
  298. <methodname>clean()</methodname> メソッドを使う際に必要です。
  299. </entry>
  300. </row>
  301. <row>
  302. <entry><emphasis>password</emphasis></entry>
  303. <entry><type>String</type></entry>
  304. <entry><constant>NULL</constant></entry>
  305. <entry>
  306. <filename>xcache.admin.pass</filename> (<acronym>MD5</acronym> ではない平文形式) です。
  307. <methodname>clean()</methodname> メソッドを使う際に必要です。
  308. </entry>
  309. </row>
  310. </tbody>
  311. </tgroup>
  312. </table>
  313. </sect2>
  314. <sect2 id="zend.cache.backends.platform">
  315. <title>Zend_Cache_Backend_ZendPlatform</title>
  316. <para>
  317. このバックエンドは、<ulink url="http://www.zend.co.jp/product/zendplatform.html">Zend Platform</ulink>
  318. 製品のコンテンツキャッシング <acronym>API</acronym> を使用します。当然、このバックエンドを使用するには
  319. Zend Platform をインストールする必要があります。
  320. </para>
  321. <para>
  322. このバックエンドはタグをサポートしています。しかし、
  323. クリーニングモード <constant>CLEANING_MODE_NOT_MATCHING_TAG</constant> はサポートしていません。
  324. </para>
  325. <para>
  326. <methodname>Zend_Cache::factory()</methodname> メソッドでこのバックエンドを指定する場合は、
  327. 'Zend' と 'Platform' の間に区切り文字を入れます。区切り文字としては
  328. '-'、'.'、' ' あるいは '_' が使用できます。
  329. </para>
  330. <programlisting language="php"><![CDATA[
  331. $cache = Zend_Cache::factory('Core', 'Zend Platform');
  332. ]]></programlisting>
  333. <para>
  334. このバックエンドではオプションを使用しません。
  335. </para>
  336. </sect2>
  337. <sect2 id="zend.cache.backends.twolevels">
  338. <title>Zend_Cache_Backend_TwoLevels</title>
  339. <para>
  340. この (拡張) バックエンドは複合型です。
  341. キャッシュレコードを、
  342. 高速 (だが制限付き) な Apc、Memcache…… および "低速"
  343. な File、Sqlite…… の 2 種類の別々のバックエンドに格納します。
  344. </para>
  345. <para>
  346. このバックエンドは priority パラメータを使用 (フロントエンドレベルで、記録開始時に指定)
  347. し、高速バックエンドの残りのスペースを用いてふたつのバックエンドの使用を最適化します。
  348. </para>
  349. <para>
  350. <methodname>Zend_Cache::factory()</methodname> メソッドでこのバックエンドを指定する場合は、
  351. 'Two' と 'Levels' の間に区切り文字を入れます。区切り文字としては
  352. '-'、'.'、' ' あるいは '_' が使用できます。
  353. </para>
  354. <programlisting language="php"><![CDATA[
  355. $cache = Zend_Cache::factory('Core', 'Two Levels');
  356. ]]></programlisting>
  357. <para>
  358. 使用可能なオプションは次のとおりです。
  359. </para>
  360. <table id="zend.cache.backends.twolevels.table">
  361. <title>TwoLevels バックエンドのオプション</title>
  362. <tgroup cols="4">
  363. <thead>
  364. <row>
  365. <entry>オプション</entry>
  366. <entry>データ型</entry>
  367. <entry>デフォルト値</entry>
  368. <entry>説明</entry>
  369. </row>
  370. </thead>
  371. <tbody>
  372. <row>
  373. <entry><emphasis>slow_backend</emphasis></entry>
  374. <entry><type>String</type></entry>
  375. <entry>File</entry>
  376. <entry>
  377. "低速" バックエンドの名前。
  378. </entry>
  379. </row>
  380. <row>
  381. <entry><emphasis>fast_backend</emphasis></entry>
  382. <entry><type>String</type></entry>
  383. <entry>Apc</entry>
  384. <entry>
  385. "高速" バックエンドの名前。
  386. </entry>
  387. </row>
  388. <row>
  389. <entry><emphasis>slow_backend_options</emphasis></entry>
  390. <entry><type>Array</type></entry>
  391. <entry><methodname>array()</methodname></entry>
  392. <entry>
  393. "低速" バックエンドのオプション。
  394. </entry>
  395. </row>
  396. <row>
  397. <entry><emphasis>fast_backend_options</emphasis></entry>
  398. <entry><type>Array</type></entry>
  399. <entry><methodname>array()</methodname></entry>
  400. <entry>
  401. "高速" バックエンドのオプション。
  402. </entry>
  403. </row>
  404. <row>
  405. <entry><emphasis>slow_backend_custom_naming</emphasis></entry>
  406. <entry><type>Boolean</type></entry>
  407. <entry><constant>FALSE</constant></entry>
  408. <entry>
  409. <constant>TRUE</constant> の場合は、引数 slow_backend を完全なクラス名として使用します。
  410. <constant>FALSE</constant> の場合は、引数をクラス名 "<classname>Zend_Cache_Backend_</classname>[...]"
  411. の最後の部分として使用します。
  412. </entry>
  413. </row>
  414. <row>
  415. <entry><emphasis>fast_backend_custom_naming</emphasis></entry>
  416. <entry><type>Boolean</type></entry>
  417. <entry><constant>FALSE</constant></entry>
  418. <entry>
  419. <constant>TRUE</constant> の場合は、引数 fast_backend を完全なクラス名として使用します。
  420. <constant>FALSE</constant> の場合は、引数をクラス名 "<classname>Zend_Cache_Backend_</classname>[...]"
  421. の最後の部分として使用します。
  422. </entry>
  423. </row>
  424. <row>
  425. <entry><emphasis>slow_backend_autoload</emphasis></entry>
  426. <entry><type>Boolean</type></entry>
  427. <entry><constant>FALSE</constant></entry>
  428. <entry>
  429. <constant>TRUE</constant> の場合は、低速バックエンドに対して require_once を行いません
  430. (独自のバックエンドを使用する場合にのみ有用です)。
  431. </entry>
  432. </row>
  433. <row>
  434. <entry><emphasis>fast_backend_autoload</emphasis></entry>
  435. <entry><type>Boolean</type></entry>
  436. <entry><constant>FALSE</constant></entry>
  437. <entry>
  438. <constant>TRUE</constant> の場合は、高速バックエンドに対して require_once を行いません
  439. (独自のバックエンドを使用する場合にのみ有用です)。
  440. </entry>
  441. </row>
  442. <row>
  443. <entry><emphasis>auto_refresh_fast_cache</emphasis></entry>
  444. <entry><type>Boolean</type></entry>
  445. <entry><constant>TRUE</constant></entry>
  446. <entry>
  447. <constant>TRUE</constant> の場合は、キャッシュレコードにヒットしたときに
  448. 高速キャッシュを自動的にリフレッシュします。
  449. </entry>
  450. </row>
  451. <row>
  452. <entry><emphasis>stats_update_factor</emphasis></entry>
  453. <entry><type>Integer</type></entry>
  454. <entry>10</entry>
  455. <entry>
  456. 高速バックエンドを使用率の計算を無効化 / 効率化します
  457. (レコードをキャッシュに書き込む際の
  458. 高速バックエンド使用率の計算は、
  459. キャッシュ書き込み x 回につき 1 回の割合でランダムに行われます)。
  460. </entry>
  461. </row>
  462. </tbody>
  463. </tgroup>
  464. </table>
  465. </sect2>
  466. <sect2 id="zend.cache.backends.zendserver">
  467. <title>Zend_Cache_Backend_ZendServer_Disk および Zend_Cache_Backend_ZendServer_ShMem</title>
  468. <para>
  469. これらのバックエンドは、キャッシュレコードの保存に
  470. <ulink url="http://www.zend.com/en/products/server/downloads-all?zfs=zf_download">Zend Server</ulink>
  471. のキャッシュ機能を使用します。
  472. </para>
  473. <para>
  474. 注意: このバックエンドでは、今のところ "タグ" がサポートされていません。
  475. また、引数 "doNotTestCacheValidity=true" もサポートされていません。
  476. </para>
  477. <para>
  478. これらのバックエンドが動作するのは、Zend Server 環境で
  479. <acronym>HTTP</acronym> あるいは <acronym>HTTPS</acronym>
  480. 越しにページをリクエストした場合のみです。
  481. コマンドラインでスクリプトを実行した場合は動作しません。
  482. </para>
  483. <para>
  484. <methodname>Zend_Cache::factory()</methodname> メソッドでこのバックエンドを指定する場合は、
  485. パラメータ <emphasis>customBackendNaming</emphasis> を <constant>TRUE</constant> とします。
  486. </para>
  487. <programlisting language="php"><![CDATA[
  488. $cache = Zend_Cache::factory('Core', 'Zend_Cache_Backend_ZendServer_Disk',
  489. $frontendOptions, $backendOptions, false, true);
  490. ]]></programlisting>
  491. <para>
  492. このバックエンドにはオプションはありません。
  493. </para>
  494. </sect2>
  495. <!-- TODO : to be translated -->
  496. <sect2 id="zend.cache.backends.static">
  497. <title>Zend_Cache_Backend_Static</title>
  498. <para>
  499. This backend works in concert with <classname>
  500. Zend_Cache_Frontend_Capture</classname> (the two must be used
  501. together) to save the output from requests as static files. This
  502. means the static files are served directly on subsequent requests
  503. without any involvement of PHP or the Zend Framework at all.
  504. </para>
  505. <para>
  506. The benefits of this cache include a large throughput increase since
  507. all subsequent requests return the static file and don't need any
  508. dynamic processing. Of course this also has some disadvantages. The
  509. only way to retry the dynamic request is to purge the cached file
  510. from elsewhere in the application (or via a cronjob if timed). It
  511. is also restricted to single-server applications where only one
  512. filesystem is used. Nevertheless, it can be a powerful means of
  513. getting more performance without incurring the cost of a proxy on
  514. single machines.
  515. </para>
  516. <para>
  517. Before describing its options, you should note this needs some
  518. changes to the default .htaccess file in order for requests to be
  519. directed to the static files if they exist. Here's an example of
  520. a simple application caching some content, including two specific
  521. feeds which need additional treatment to serve a correct
  522. Content-Type header:
  523. </para>
  524. <programlisting language="text"><![CDATA[
  525. AddType application/rss+xml .xml
  526. AddType application/atom+xml .xml
  527. RewriteEngine On
  528. RewriteCond %{REQUEST_URI} feed/rss$
  529. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.xml -f
  530. RewriteRule .* cached/%{REQUEST_URI}.xml [L,T=application/rss+xml]
  531. RewriteCond %{REQUEST_URI} feed/atom$
  532. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.xml -f
  533. RewriteRule .* cached/%{REQUEST_URI}.xml [L,T=application/atom+xml]
  534. RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
  535. RewriteRule ^/*$ cached/index.html [L]
  536. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.(html|xml|json|opml|svg) -f
  537. RewriteRule .* cached/%{REQUEST_URI}.%1 [L]
  538. RewriteCond %{REQUEST_FILENAME} -s [OR]
  539. RewriteCond %{REQUEST_FILENAME} -l [OR]
  540. RewriteCond %{REQUEST_FILENAME} -d
  541. RewriteRule ^.*$ - [NC,L]
  542. RewriteRule ^.*$ index.php [NC,L]
  543. ]]></programlisting>
  544. <para>
  545. The above assumes static files are cached to the directory ./public/cached.
  546. We'll cover the option setting this location, "public_dir", below.
  547. </para>
  548. <para>
  549. Due to the nature of static file caching, the backend class offers two
  550. additional methods: <methodname>remove()</methodname> and <methodname>
  551. removeRecursively()</methodname>. Both accept a request URI, which when
  552. mapped to the "public_dir" where static files are cached, and has a
  553. pre-stored extension appended, provides the name of either a static
  554. file to delete, or a directory path to delete recursively. Due to the
  555. restraints of <classname>Zend_Cache_Backend_Interface</classname>, all
  556. other methods such as <classname>save()</classname> accept an ID which
  557. is calculated by applying bin2hex() to a request URI.
  558. </para>
  559. <para>
  560. Given the level at which static caching operates, static file caching
  561. is addressed for simpler use with the <classname>
  562. Zend_Controller_Action_Helper_Cache</classname> action helper. This helper
  563. assists in setting which actions of a controller to cache, with what tags,
  564. and with which extension. It also offers methods for purging the cache by
  565. request URI or tag. Static file caching is also assisted by <classname>
  566. Zend_Cache_Manager</classname> which includes pre-configured configuration
  567. templates for a static cache (as Zend_Cache_Manager::PAGECACHE or "page").
  568. The defaults therein can be configured as needed to set up a "public_dir"
  569. location for caching, etc.
  570. </para>
  571. <note>
  572. <para>
  573. It should be noted that the static cache actually uses a secondary
  574. cache to store tags (obviously we can't store them elsewhere since
  575. a static cache does not invoke PHP if working correctly). This is
  576. just a standard Core cache, and should use a persistent backend such
  577. as File or TwoLevels (to take advantage of memory storage without
  578. sacrificing permanent persistance). The backend includes the option
  579. "tag_cache" to set this up (it is obligatory), or the <methodname>
  580. setInnerCache()</methodname> method.
  581. </para>
  582. </note>
  583. <table id="zend.cache.backends.static.table">
  584. <title>Static Backend Options</title>
  585. <tgroup cols="4">
  586. <thead>
  587. <row>
  588. <entry>Option</entry>
  589. <entry>Data Type</entry>
  590. <entry>Default Value</entry>
  591. <entry>Description</entry>
  592. </row>
  593. </thead>
  594. <tbody>
  595. <row>
  596. <entry><emphasis>public_dir</emphasis></entry>
  597. <entry><type>String</type></entry>
  598. <entry>NULL</entry>
  599. <entry>
  600. Directory where to store static files. This must exist
  601. in your public directory.
  602. </entry>
  603. </row>
  604. <row>
  605. <entry><emphasis>file_locking</emphasis></entry>
  606. <entry><type>Boolean</type></entry>
  607. <entry><constant>TRUE</constant></entry>
  608. <entry>
  609. Enable or disable file_locking : Can avoid cache corruption under
  610. bad circumstances but it doesn't help on multithread webservers
  611. or on <acronym>NFS</acronym> filesystems...
  612. </entry>
  613. </row>
  614. <row>
  615. <entry><emphasis>read_control</emphasis></entry>
  616. <entry><type>Boolean</type></entry>
  617. <entry><constant>TRUE</constant></entry>
  618. <entry>
  619. Enable / disable read control : if enabled, a control key is
  620. embedded in the cache file and this key is compared with the
  621. one calculated after the reading.
  622. </entry>
  623. </row>
  624. <row>
  625. <entry><emphasis>read_control_type</emphasis></entry>
  626. <entry><type>String</type></entry>
  627. <entry>'crc32'</entry>
  628. <entry>
  629. Type of read control (only if read control is enabled). Available values
  630. are : 'md5' (best but slowest), 'crc32' (lightly less safe but faster,
  631. better choice), 'adler32' (new choice, faster than crc32),
  632. 'strlen' for a length only test (fastest).
  633. </entry>
  634. </row>
  635. <row>
  636. <entry><emphasis>cache_file_umask</emphasis></entry>
  637. <entry><type>Integer</type></entry>
  638. <entry>0700</entry>
  639. <entry>
  640. umask for cached files.
  641. </entry>
  642. </row>
  643. <row>
  644. <entry><emphasis>cache_directory_umask</emphasis></entry>
  645. <entry><type>Integer</type></entry>
  646. <entry>0700</entry>
  647. <entry>
  648. Umask for directories created within public_dir.
  649. </entry>
  650. </row>
  651. <row>
  652. <entry><emphasis>file_extension</emphasis></entry>
  653. <entry><type>String</type></entry>
  654. <entry>'.html'</entry>
  655. <entry>
  656. Default file extension for static files created. This
  657. can be configured on the fly, see <methodname>
  658. Zend_Cache_Backend_Static::save()</methodname> though
  659. generally it's recommended to rely on <classname>
  660. Zend_Controller_Action_Helper_Cache</classname> when
  661. doing so since it's simpler that way than messing with
  662. arrays/serialization manually.
  663. </entry>
  664. </row>
  665. <row>
  666. <entry><emphasis>index_filename</emphasis></entry>
  667. <entry><type>String</type></entry>
  668. <entry>'index'</entry>
  669. <entry>
  670. If a request URI does not contain sufficient information
  671. to construct a static file (usually this means an index
  672. call, e.g. URI of '/'), the index_filename is used instead.
  673. So '' or '/' would map to 'index.html' (assuming the default
  674. file_extension is '.html').
  675. </entry>
  676. </row>
  677. <row>
  678. <entry><emphasis>tag_cache</emphasis></entry>
  679. <entry><type>Object</type></entry>
  680. <entry>NULL</entry>
  681. <entry>
  682. Used to set an 'inner' cache utilised to store tags
  683. and file extensions associated with static files. This
  684. MUST be set or the static cache cannot be tracked and
  685. managed.
  686. </entry>
  687. </row>
  688. <row>
  689. <entry><emphasis>disable_caching</emphasis></entry>
  690. <entry><type>Boolean</type></entry>
  691. <entry>FALSE</entry>
  692. <entry>
  693. If set to TRUE, static files will not be cached. This
  694. will force all requests to be dynamic even if marked
  695. to be cached in Controllers. Useful for debugging.
  696. </entry>
  697. </row>
  698. </tbody>
  699. </tgroup>
  700. </table>
  701. </sect2>
  702. </sect1>
  703. <!--
  704. vim:se ts=4 sw=4 et:
  705. -->