4.12 Static contents cache functionality

You can cache the static contents file stored on the disk in the memory, return the file from the cache to the browser, and can reduce the response time of static contents.

You can use this functionality only in Windows version.

Organization of this section
(1) Embedding the module
(2) How to set directives
(3) Triggers of file cache, cache update, and cache deletion
(4) Memory usage
(5) Note

(1) Embedding the module

Embed the mod_hws_cache module to use the static contents cache functionality. Specify the configuration file (httpsd.conf) as follows to embed the mod_hws_cache module:

LoadModule hws_cache_module modules/mod_hws_cache.so

(2) How to set directives

Specify the handler name hws_cache to use the cache functionality in the AddHandler directive or the SetHandler directive.

(a) Settings to cache the file with a specific extension

Set the AddHandler directive to cache the file with a specific extension. The setting method is as follows:

<Directory "<Cosminexus-installation-directory>/httpsd/htdocs">
 AddHandler hws_cache .html
</Directory>

(b) Settings to cache the file under a specific URL

Set the SetHandler directive to cache the file under a specific URL. The setting method is as follows:

<Directory "<Cosminexus-installation-directory>/httpsd/icons">
<Files "?*">
 SetHandler hws_cache
</Files>
</Directory>

(3) Triggers of file cache, cache update, and cache deletion

(a) Trigger to cache a file

The trigger to cache a file is shown below. However, if the file size is larger than the size set in the HWSContentCacheMaxFileSize directive, the file is not cached.

(b) Trigger to update the cache

The trigger in which cache is updated is shown below. However, if the file size is bigger than the size set in the HWSContentCacheMaxFileSize directive, the file is not cached.

(c) Trigger to delete the cache

The trigger in which cache is deleted is shown below:

(4) Memory usage

You can calculate the maximum memory size used in the static contents cache functionality with the following formula:

Formula

(HWSContentCacheMaxFileSize [Figure] ThreadsPerChild) + HWSContentCacheSize

(5) Note

Do not cache the files placed in the URL in which the reverse proxy, CGI, and other dynamic content processes are performed. If you specify files as files to be cached by mistake, dynamic content might not be processed correctly.

The following is a usage example:

ScriptAlias /cgi-bin/ "<Cosminexus-installation-directory>/httpsd/cgi-bin/"
                                                              *1
LoadModule hws_cache_module modules/mod_hws_cache.so
<Directory "<Cosminexus-installation-directory>/httpsd/icons/">
                                                *2
<Files "?*">
 SetHandler hws_cache
</Files>
</Directory>

# Do not duplicate the path that is set in underlined *1 and *2.
When "<Cosminexus-installation-directory>/httpsd/cgi-bin/" is set as *2, the CGI program is responded as static file, and you may get unexpected results such that contents of CGI programs are leaked.