Minimal configuration is required to set up the depot server behind a caching proxy. With the exception of the catalog attributes file (see Cache Considerations for the Catalog Attributes File) and repository search results (see Cache Considerations for Search), all files served are unique and therefore safe to cache indefinitely if necessary. Also, all depot responses contain the appropriate HTTP headers to ensure files in the cache do not become stale by mistake.
See the Apache Caching Guide for more information about configuring Apache as a caching proxy, including using the htcacheclean command to control the size of the cache. See Developing System Services in Oracle Solaris 11.3 for information about how to create a periodic or scheduled SMF service to run htcacheclean.
Use the CacheRoot directive to specify the directory to contain the cached files. Make sure the specified directory is writable by the Apache process. No explicit error message is output if Apache cannot write to this directory.
Apache allows you to enable caching for specific directories. You probably want your repository server to cache all of the content on the server, as shown in the following directive.
CacheEnable disk /
Use the CacheMaxFileSize directive to set the maximum size of any single file to be cached. The Apache default of 1 MB might be too small for most repositories. The following directive sets the maximum size of a cached file to 1 GB.
Adjust the directory structure of the on-disk cache for the best performance with the underlying file system. In a ZFS dataset, multiple directory levels affect performance more than the number of files in one directory. Therefore, configure one directory level with a large number of files in each directory. Use the CacheDirLevels and CacheDirLength directives to control the directory structure. Set CacheDirLevels to 1. Set CacheDirLength to a value that results in a good balance between the number of directories and the number of files per directory. The value of 2 set below will generate 4096 directories. See the Apache Disk-based Caching documentation for more information.
CacheDirLevels 1 CacheDirLength 2
The repository catalog attributes file (catalog.attrs) contains the current status of the repository catalog. This file can be large enough to warrant caching. However, this file becomes stale if the catalog of the back-end repository has changed. You can use one of the following two methods to address this issue.
Do not cache this file. This solution works best if the repository server runs in a high-bandwidth environment where the additional traffic is not an important consideration. The following partial httpd.conf file shows how to specify not to cache the catalog.attrs file:
<LocationMatch ".*/catalog.attrs"> Header set Cache-Control no-cache </LocationMatch>
Prune this file from the cache whenever the catalog of the back-end repository is updated.
Searching a package repository generates custom responses based on the request. Therefore, search results are not well suited for being cached. The depot server sets the appropriate HTTP headers to make sure search results do not become stale in a cache. However, the expected bandwidth savings from caching are small. The following partial httpd.conf file shows how to specify not to cache search results.
<LocationMatch ".*/search/\d/.*"> Header set Cache-Control no-cache </LocationMatch>