summaryrefslogtreecommitdiff
path: root/docs/manual/mod/mod_mem_cache.xml
blob: ef63f50ae4e7eb878289966e9cb17c1cb1bca250 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
<!-- $LastChangedRevision$ -->

<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<modulesynopsis metafile="mod_mem_cache.xml.meta">

<name>mod_mem_cache</name>
<description>Content cache keyed to URIs</description>
<status>Experimental</status>
<sourcefile>mod_mem_cache.c</sourcefile>
<identifier>mem_cache_module</identifier>

<summary>
    <note type="warning">
      This module is experimental. Documentation is still under
      development...
    </note>

    <p>This module <em>requires</em> the service of <module
    >mod_cache</module>. It acts as a support module for <module
    >mod_cache</module> and provides a memory based storage manager.
    <module>mod_mem_cache</module> can be configured to operate in two
    modes: caching open file descriptors or caching objects in heap storage.
    <module>mod_mem_cache</module> is most useful when used to cache locally
    generated content or to cache backend server content for <module
    >mod_proxy</module> configured for <directive module="mod_proxy"
    >ProxyPass</directive> (aka <dfn>reverse proxy</dfn>).</p>

    <p>Content is stored in and retrieved from the cache using URI based
    keys. Content with access protection is not cached.</p>
</summary>
<seealso><module>mod_cache</module></seealso>
<seealso><module>mod_disk_cache</module></seealso>

<directivesynopsis>
<name>MCacheSize</name>
<description>The maximum amount of memory used by the cache in
KBytes</description>
<syntax>MCacheSize <var>KBytes</var></syntax>
<default>MCacheSize 100</default>
<contextlist><context>server config</context></contextlist>

<usage>
    <p>The <directive>MCacheSize</directive> directive sets the maximum
    amount of memory to be used by the cache, in KBytes (1024-byte units).
    If a new object needs to be inserted in the cache and the size of the
    object is greater than the remaining memory, objects will be removed
    until the new object can be cached. The object to be removed is
    selected using the algorithm specified by <directive
    module="mod_mem_cache">MCacheRemovalAlgorithm</directive>.</p>

    <example><title>Example</title>
      MCacheSize 700000
    </example>

    <note><title>Note</title>
      <p>The <directive>MCacheSize</directive> value must be greater than
      the value specified by the <directive module="mod_mem_cache"
      >MCacheMaxObjectSize</directive> directive.</p>
    </note>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>MCacheMaxObjectCount</name>
<description>The maximum number of objects allowed to be placed in the
cache</description>
<syntax>MCacheMaxObjectCount <var>value</var></syntax>
<default>MCacheMaxObjectCount 1009</default>
<contextlist><context>server config</context></contextlist>

<usage>
    <p>The <directive>MCacheMaxObjectCount</directive> directive sets the
    maximum number of objects to be cached. The value is used to create the
    open hash table. If a new object needs to be inserted in the cache and
    the maximum number of objects has been reached, an object will be
    removed to allow the new object to be cached. The object to be removed
    is selected using the algorithm specified by <directive
    module="mod_mem_cache">MCacheRemovalAlgorithm</directive>.</p>

    <example><title>Example</title>
      MCacheMaxObjectCount 13001
    </example>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>MCacheMinObjectSize</name>
<description>The minimum size (in bytes) of a document to be allowed in the
cache</description>
<syntax>MCacheMinObjectSize <var>bytes</var></syntax>
<default>MCacheMinObjectSize 0</default>
<contextlist><context>server config</context></contextlist>

<usage>
    <p>The <directive>MCacheMinObjectSize</directive> directive sets the
    minimum size in bytes of a document for it to be considered
    cacheable.</p>

    <example><title>Example</title>
      MCacheMinObjectSize 10000
    </example>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>MCacheMaxObjectSize</name>
<description>The maximum size (in bytes) of a document allowed in the
cache</description>
<syntax>MCacheMaxObjectSize <var>bytes</var></syntax>
<default>MCacheMaxObjectSize 10000</default>
<contextlist><context>server config</context></contextlist>

<usage>
    <p>The <directive>MCacheMaxObjectSize</directive> directive sets the
    maximum allowable size, in bytes, of a document for it to be considered
    cacheable.</p>

    <example><title>Example</title>
      MCacheMaxObjectSize 6400000
    </example>

    <note><title>Note</title>
      <p>The value of <directive>MCacheMaxObjectSize</directive> must be
      greater than the value specified by the <directive
      module="mod_mem_cache">MCacheMinObjectSize</directive> directive.</p>
    </note>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>MCacheRemovalAlgorithm</name>
<description>The algorithm used to select documents for removal from the
cache</description>
<syntax>MCacheRemovalAlgorithm LRU|GDSF</syntax>
<default>MCacheRemovalAlgorithm GDSF</default>
<contextlist><context>server config</context></contextlist>

<usage>
    <p>The <directive>MCacheRemovalAlgorithm</directive> directive specifies
    the algorithm used to select documents for removal from the cache.
    Two choices are available:</p>

    <dl>
      <dt><code>LRU</code> (Least Recently Used)</dt>
      <dd><code>LRU</code> removes the documents that have not been accessed
      for the longest time.</dd>

      <dt><code>GDSF</code> (GreadyDual-Size)</dt>
      <dd><code>GDSF</code> assigns a priority to cached documents based
      on the cost of a cache miss and the size of the document. Documents
      with the lowest priority are removed first.</dd>
    </dl>

    <example><title>Example</title>
      MCacheRemovalAlgorithm GDSF<br />
      MCacheRemovalAlgorithm LRU
    </example>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>MCacheMaxStreamingBuffer</name>
<description>Maximum amount of a streamed response to buffer in memory
before declaring the response uncacheable</description>
<syntax>MCacheMaxStreamingBuffer <var>size_in_bytes</var></syntax>
<default>MCacheMaxStreamingBuffer the smaller of 100000 or MCacheMaxObjectSize</default>
<contextlist><context>server config</context>
</contextlist>

<usage>
    <p>The <directive>MCacheMaxStreamingBuffer</directive> directive
    specifies the maximum number of bytes of a streamed response to
    buffer before deciding that the response is too big to cache.
    A streamed response is one in which the entire content is not
    immediately available and in which the <code>Content-Length</code>
    may not be known. Sources of streaming responses include proxied
    responses and the output of CGI scripts. By default, a streamed
    response will <em>not</em> be cached unless it has a
    <code>Content-Length</code> header. The reason for this is to
    avoid using a large amount of memory to buffer a partial response
    that might end up being too large to fit in the cache.
    The <directive>MCacheMaxStreamingBuffer</directive> directive allows
    buffering of streamed responses that don't contain a
    <code>Content-Length</code> up to the specified maximum amount of
    space. If the maximum buffer space is reached, the buffered
    content is discarded and the attempt to cache is abandoned.</p>

    <note><title>Note:</title>
      <p>Using a nonzero value for <directive>MCacheMaxStreamingBuffer</directive> 
      will not delay the transmission of the response to the client.
      As soon as <module>mod_mem_cache</module> copies a block of streamed
      content into a buffer, it sends the block on to the next output
      filter for delivery to the client.</p>
    </note>

    <example>
      # Enable caching of streamed responses up to 64KB:<br />
      MCacheMaxStreamingBuffer 65536
    </example>
</usage>
</directivesynopsis>

</modulesynopsis>