Configuring Apache to Cache Static Content via mod_disk_cache

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"
  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/
  3. Restart Apache after both modifications are complete.


  • 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.

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

10 Archived comments

  1. User avatar

    Joe Gorse

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

    02 Jul 2012
    1. User avatar

      James Gray [Atlassian]

      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.

      02 Jul 2012
  2. User avatar

    DI2E SysAdmin

    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.)

    01 Aug 2013
    1. User avatar

      Bill Arconati

      You might consider asking your question at to cast a wider net of potential "answerers."

      02 Aug 2013
  3. User avatar

    Ron Herzing

    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.

    24 Feb 2014
  4. User avatar

    Stephen Gurnick

    Is this Apache config for setting up mod_disk_cache specific to only Confluence or is it also relevant for JIRA? Does JIRA serve static content and does it make sense to use this same configuration for the intended performance benefits of not using the JVM for caching?

    17 Jun 2014
    1. User avatar

      Torben Hoeft

      Using cache is also recommended for JIRA by several best practices like Performance Tuning Atlassian #3 .

      If possible play with it on a test system. Use JIRA Data Generator and a monitoring like javamelody to see the impact on your setup.

      04 Aug 2014
  5. User avatar

    Mikhail T

    Should not the /images subdirectory be similarly cached? Any others?

    29 Oct 2014
  6. User avatar

    Jan-Peter Rusch

    I just did some testing with our Confluence testing environment:

    • Windows Server 2008 R2 (Running on VMware)
      • 4GB RAM
    • Apache HTTPD 2.4.9 32bit
      • All traffic is served via https
      • Apache is terminating the SSL connections
    • Confluence 5.7.1 64bit (Tomcat 7.0.52)
      • JVM Heap 1024MB - 2535MB

    Configuration 1:

    Apache & Tomcat are connected via mod_jk, no Apache caching is used.

    Configuration 2:

    Apache & Tomcat are connected via mod_proxy_ajp, Apache mod_cache & mod_cache_disk is used with default configuration:

    cacheEnable /s "d:/Apache/cache"
    cacheEnable /confluence/s "d:/Apache/cache"

    Configuration 3:

    Apache & Tomcat are connected via mod_proxy_http. Apache mod_cache & mod_cache_disk is used with default configuration:

    cacheEnable /s "d:/Apache/cache"
    cacheEnable /confluence/s "d:/Apache/cache"


    Apache disk caching is working in configuration 2&3 as cache directory is filling up with files.

    I found out that the load time of various Confluence pages are about 3-4 times faster when using configuration 1 (without any caching on Apache side), even when reloading the same page more than once.

    This result was verified on our production site with a fixed JVM heap of 8GB. We expected to see a speed up using Apache side caching but this was definitely not the case.

    I assume that caching on Tomcat/Confluence side has improved a lot with 5.7. Please note that Apache HTTPD & Confluence are running on the same machine on both setups (Test & Production). Database is MySQL 5.6.22 running on a remote DB-Server.

    So, I guess, there is no general suggestion but do some testing on your own environment. Comments & remarks from your side are very welcome!

    10 Mar 2015
  7. User avatar

    Azat Khadiev

    <IfModule mod_cache_disk.c>
    # "/s" is where Confluence serves "static" stuff. Instruct Apache to ca$
    CacheEnable disk /s
    CacheIgnoreHeaders Set-Cookie
    CacheRoot "/var/cache/apache2/mod_cache_disk"


    for new module name in apache 2.4

    29 Jun 2015
Powered by Confluence and Scroll Viewport