Maintains a cache of authentication credentials, so that a new backend lookup is not required for every authenticated request.
Some users of more heavyweight authentication such as SQL database
lookups (
The authentication cache should be used where authentication
lookups impose a significant load on the server, or a backend or
network. Authentication by file (
The basic rules to cache for a provider are:
A simple usage example to accelerate
Module developers should note that their modules must be enabled
for caching with
This directive is not normally necessary: it is implied if authentication caching is enabled anywhere in httpd.conf. However, if it is not enabled anywhere in httpd.conf it will by default not be initialised, and is therefore not available in a .htaccess context. This directive ensures it is initialised so it can be used in .htaccess.
This is a server-wide setting to select a provider for the shared object cache, followed by optional arguments for that provider. Some possible values for provider-name are "dbm", "dc", "memcache", or "shmcb", each subject to the appropriate module being loaded. If not set, your platform's default will be used.
This directive specifies an authentication provider or providers
to cache for. Credentials found by a provider not listed in an
For example, to cache credentials found by
Caching authentication data can be a security issue, though short-term caching is unlikely to be a problem. Typically a good solution is to cache credentials for as long as it takes to relieve the load on a backend, but no longer, though if changes to your users and passwords are infrequent then a longer timeout may suit you. The default 300 seconds (5 minutes) is both cautious and ample to keep the load on a backend such as dbd (SQL database queries) down.
This should not be confused with session timeout, which is an entirely separate issue. However, you may wish to check your session-management software for whether cached credentials can "accidentally" extend a session, and bear it in mind when setting your timeout.
This directive specifies a string to be used along with the supplied username (and realm in the case of Digest Authentication) in constructing a cache key. This serves to disambiguate identical usernames serving different authentication areas on the server.
Two special values for this are directory
, which uses
the directory context of the request as a string, and server
which uses the virtual host name.
The default is directory
, which is also the most
conservative setting. This is likely to be less than optimal, as it
(for example) causes $app-base, $app-base/images,
$app-base/scripts and $app-base/media each to
have its own separate cache key. A better policy is to name the
Contexts can be shared across different areas of a server, where credentials are shared. However, this has potential to become a vector for cross-site or cross-application security breaches, so this directive is not permitted in .htaccess contexts.