Optimizing S3Store Cache Settings

This article documents an issue with using S3Store where the Application Server's temporary directory might grow a lot more than expected. The contents of this article apply to users of Liferay DXP, and concern environments that use S3Store for the Documents and Media storage.


This happens because the Liferay platform starts to make a cache for all uploaded files to the Document Library when using S3Store. Although the cache is emptied on a specific number of days (default: 7) or after a specific number of calls (default: 100), if you are running on limited disk space or would like to ensure that your S3Store cache is optimized to the environment's needs, the S3Store cache can be adjusted in the following manner:

  1. Go to Menu Bar > Control Panel > Configuration > System Settings > Foundation > S3 Store Configuration
  2. Find the following fields:
    1. Cache Directory Clean Up Expunge
      1. The number of days that files should be left in the temporary directory before they are eligible for deletion by the cleanup process. Default value: 7. Please be advised that the Cache Directory Clean Up Expunge uses the modified date, rather than the create date of the file. In other words, if the cached file is modified then the counter is reset.
    2. Cache Directory Clean Up Frequency
      1. The number of calls to S3Store#getFile() before triggering the clean up process. Default value: 100
  3. Adjust the values to your needs

For example, if you have an environment that is lean on disk space, setting Cache Directory Clean Up Frequency to 1 and Cache Directory Clean Up Expunge to 5 will trigger the clean up process and remove the cached files older than 5 days upon each access. 

Please note that this configuration may affect hard disk drive performance if there is heavy use of the Documents and Media in S3Store, so it is important to tune it to your environment's need.

Was this article helpful?
4 out of 4 found this helpful