Apache HTTP Server Version 2.0

Apache > HTTP Server > Documentation > Version 2.0 > Modules

# Apache Module mod_mem_cache

Description: | Content cache keyed to URIs
Status: | Experimental
Module Identifier: | mem_cache_module
Source File: | mod_mem_cache.c

### Summary

This module is experimental. Documentation is still under development...

mod_mem_cache implements an in-memory based storage manager. mod_mem_cache can be configured to operate in two modes: caching open file descriptors or caching objects in heap storage. mod_mem_cache is most useful when used to cache locally generated content or to cache backend server content for `mod_proxy` configured for ProxyPass (aka reverse proxy)

`mod_mem_cache` requires the services of `mod_cache`.

Content stored and retrived keyed to the URL. Content with access protections is not cached.

### Directives

## MCacheMaxObjectCount Directive

Description: | The maximum number of objects allowed to be placed in the cache
Syntax: | MCacheMaxObjectCount value
Default: | `MCacheMaxObjectCount 1009`
Context: | server config
Status: | Experimental
Module: | mod_mem_cache

The `MCacheMaxObjectCount` directive sets the maximum number of objects to be cached. If a new entry needs to be inserted in the cache and the maximum number of objects is reached, an entry will be removed to allow the new entry be cached.

The size must be greater than `MCacheMinObjectSize`.
The value of `MCacheMaxObjectCount` is used to create the open hash table.

`MCacheMaxObjectCount 13001
`

## MCacheMaxObjectSize Directive

Description: | The maximum size (in bytes) of an object to be placed in the cache
Syntax: | MCacheMaxObjectSize bytes
Default: | `MCacheMaxObjectSize 10000`
Context: | server config
Status: | Experimental
Module: | mod_mem_cache

The `MCacheMaxObjectSize` directive sets the maximum size of an object to be cached.

`MCacheMaxObjectSize 6400000
`

## MCacheMinObjectSize Directive

Description: | The minimum size (in bytes) of an object to be placed in the cache
Syntax: | MCacheMinObjectSize bytes
Default: | `MCacheMinObjectSize 0`
Context: | server config
Status: | Experimental
Module: | mod_mem_cache

The `MCacheMinObjectSize` directive sets the minimum size in bytes of an object to be cached.

`MCacheMinObjectSize 10000
`

## MCacheRemovalAlgorithm Directive

Description: | The algorithm used to remove entries from the cache
Syntax: | MCacheRemovalAlgorithm algorithm
Default: | `MCacheRemovalAlgorithm GDSF`
Context: | server config
Status: | Experimental
Module: | mod_mem_cache

The `MCacheRemovalAlgorithm` directive sets the algorithm used to remove entries from the cache. Two choices are available:
LRU (Least Recently Used): LRU removes the objects that have not been accessed for the longest time.
GDSF (GreadyDual-Size): This algorithm assigns priority to cached objects based on the coast of a cache miss and the size of the object. Objects with smallest priority are removed first.

`MCacheRemovalAlgorithm GDSF
MCacheRemovalAlgorithm LRU
`

## MCacheSize Directive

Description: | The maximum amount of memory used by the cache in KBytes
Syntax: | MCacheSize KBytes
Default: | `MCacheSize 100`
Context: | server config
Status: | Experimental
Module: | mod_mem_cache

The `MCacheSize` directive sets the desired space usage of the cache, in KBytes (1024-byte units). If a new entry needs to be inserted in the cache and the size of the entry is greather than the remaining size, entries will be removed until the new entry could be cached. The removed entry is decided base on the `MCacheRemovalAlgorithm` algorithm

The size must be greater than `MCacheMaxObjectSize`.

`MCacheSize 700000
`