Web Performance Cache

From Mac OS X Server FAQ

Jump to: navigation, search

The file /etc/webperfcache/webperfcache.conf holds the configuration for the web performance cache, and also contains a brief description of this service:

webperfcache is a front-end HTTP/1.0 server designed to sit between your HTTP port(s) and the
Apache 1.3.x httpd server. To comply with HTTP/1.1 clients, webperfcache only caches requests
which result in OK/200 responses. Requests which contain headers that indicate that their
response is not or should not be cacheable are forwarded asis to the Apache httpd server (all
non "GET" requests get forwarded). Responses that contain headers that indicate they may not
be cached are not cached either. webperfcache only hashes the file name, the HTTP version and
the "Host" header (if any) f or any given request.

If you are using the Apache httpd server, you should make sure that mod_expires is enabled and properly configured. Also make sure your CGIs return a "Cache-Control: no-cache" header if you elect to make your dynamically generated content not cacheable. webperfcache will not cache responses that have a life span of less than 5 s (may get changed using WebPerfCacheMinAgeForCaching). Furthermore, regarding content negotiation, it is assumed the Apache httpd server tags all responses returned after content negotiation as non-cacheable (HTTP /1.0 clients) or adds the "Content-Location" header to the response (HTTP/1.1 clients). webperfcache would not cache such responses.

Note - the last few lines of this file are written by the server-resident component of the Server Admin app. Any changes made there directly may be overwritten.

When the web performance cache is enabled for ANY site, the following things happen:

  • All sites in /etc/httpd/sites are re-written to listen on port 16080
  • Listen and NameVirtualHost directives are re-written in /etc/httpd/sites/virtual_host_global.conf
  • The webperfcache config file /etc/webperfcache/webperfcache.conf is updated to include directives for each site for which the performance cache is enabled
  • The process webperfcache is started and listens on port 80 on the designated IP address(es)

webperfcache handles all incoming requests on port 80 for the designated IP address(es), and deals with the requests as follows:

  • If the requested site is NOT configured to use the performance cache: After examining the http HOST header supplied by the requesting http client, webperfcache can determine if the request is destined for a site that is configured to use the performance cache. If the site is configured NOT to use the cache, then webperfcache will fetch the requested page from apache on behalf of the user, and then feed that back to the client over the existing TCP connection. At no time should the http client be redirected to port 16080 by webperfcache itself (historical note: this is probably not how this service has always operated in Mac OS X Server). Also note that there may be *other* reasons for a redirect to 16080; perhaps if a web application constructs a self-referencing URL based on its apache configuration (clarification / examples here would help).
  • If the requested site IS configured to use the performance cache: webperfcache will search for the requested resource in the memory cache, except in situations mentioned in the webperfcache.conf comments (there are probably additional circumstances in which the webperfcache can be instructed to not attempt to use the cache for a given request). If the requested resource exists in the cache, then it is retrieved from the cache and sent to the client. If the requested resource is NOT in the cache, but can be cached (based on aforementioned criteria), webperfcache again retrieves the page from apache and sends it to the client, but this time webperfcache leaves a copy in the cache.
Personal tools
Toolbox