Documentation for Confluence 5.4.
Documentation for Confluence OnDemand and earlier versions of Confluence is available too.

Skip to end of metadata
Go to start of metadata

To improve performance of a large Confluence site, we recommend that you move the caching of static content from the JVM into Apache. This will prevent the JVM from having a number of long running threads serving up static content.

Static content in Confluence includes most JavaScript, CSS and image files which are included with the application or an installed plugin. This content will be cached by Apache in this configuration. User-provided content like space logos, attachments or embedded images are not considered static content and will not be cached.

Note: This page documents a configuration of Apache, rather than of Confluence itself. Atlassian will support Confluence with this configuration, but we cannot guarantee to help you debug problems with Apache. Please be aware that this material is provided for your information only, and that you use it at your own risk.

Configuring Apache mod_disk_cache

 To configure Apache to cache static Confluence content:

  1. Add a mod_disk_cache stanza to the virtual host configuration:

    <IfModule mod_disk_cache.c>
      # "/s" is where Confluence serves "static" stuff. Instruct Apache to cache it:
      CacheEnable disk /s
      CacheIgnoreHeaders Set-Cookie
      CacheRoot "/var/cache/mod_proxy"
    </IfModule>
  2. Configure Apache to load mod_disk_cache. For example, in our server configuration this is done in /etc/httpd/conf/httpd.conf:

    LoadModule disk_cache_module modules/mod_disk_cache.so
  3. Restart Apache after both modifications are complete.

Notes

  • Please refer to the Apache documentation for mod_disk_cache.
  • If you encounter problems where users are served stale content, you may need to purge the Apache cache directory (/var/cache/mod_proxy in the above configuration) after a Confluence or plugin upgrade. This is a simple 3 step process:
    • Shut down Apache.
    • Clear the cache directory. For example: sudo rm -r /var/cache/mod_proxy/*
    • Restart Apache.
  • Ensure that you are running the htcacheclean daemon in order to prevent excessive use of disk space. In our situation we ran it like this:

    sudo htcacheclean -d30 -n -t -p /var/cache/mod_proxy -l 512M

    This will purge content once the cache reaches 512M every 30 minutes.  See the Apache documentation for htcacheclean for details of the options.

  • No labels

5 Comments

  1. As an alternative to htcacheclean, consider setting "MCacheSize 512000".

    1. The MCacheSize directive is limited to use with Apache's mod_mem_cache whereas this document is specifically about leveraging persistent file system cache via Apache's mod_disk_cache.  Unfortunately mod_disk_cache doesn't have a directly configurable upper bound on the amount of disk space it will consume, hence the need for the htcacheclean helper process.  However, if you know your cache size is relatively small and have the RAM to spare, then running mod_mem_cache could work very well for you.

  2. I would like to use a controlled upstream proxy/caching server to cache Atlassian static content.  Is there any way to modify the cache-related http headers to allow this? (I see how the disk cache would work on a local Apache httpd installation, but I would like to support Atlassian tools behind a set of remote reverse proxy / load-balancers.)

    1. You might consider asking your question at http://answers.atlassian.com/ to cast a wider net of potential "answerers."

  3. Consider adding "htcacheclean -d30 -n -t -p /var/cache/mod_proxy -l 512M" to /etc/rc.local so that htcacheclean will run after a reboot.