How can I automate the RefreshCache operation on Storage Gateway?

Last updated: 2020-09-25

I have a Network File System (NFS) or Server Message Block (SMB) file share on my AWS Storage Gateway file gateway. The file gateway is associated with an Amazon Simple Storage Service (Amazon S3) bucket. However, when I upload files directly to the bucket, I can't see the files on my file share. How can I automate the refresh of my file share?


Storage Gateway updates the file share cache automatically when you write files to the cache locally using the file share. However, Storage Gateway doesn't automatically update the cache when you upload a file directly to Amazon S3. When you do this, you must perform a RefreshCache operation to see the changes on the file share.

Storage Gateway allows you to automate the RefreshCache operation based on a Time To Live (TTL) value. TTL is the length of time since the last refresh. When a user accesses the file directory after the TTL value, the file gateway refreshes the directory's contents from the S3 bucket. Valid TTL values for automating the RefreshCache operation range from 300 seconds to 2,592,000 seconds (5 minutes to 30 days).

Note: After your specified TTL value expires, the file gateway invokes the ListObjects Amazon S3 API call at the folder level. If you set TTL to a low value, then this can result in more Amazon S3 API requests.

To automate the RefreshCache operation using the Storage Gateway console, follow these steps:

  1. Open the Storage Gateway console.
  2. Choose File shares.
  3. Choose the file share that you want to automate the RefreshCache operation for.
  4. Select Automated cache refresh from S3 after, and then enter the TTL value for your use case.
  5. Choose Save.

To automate the RefreshCache operation using the Storage Gateway API, you can use the UpdateNFSFileShare API call or the UpdateSMBFileShare API call. For both API calls, you update the CacheAttributes parameter to automate the RefreshCache operation.

To run RefreshCache at one point in time instead of automating the operation, see Why aren't changes on my Amazon S3 bucket showing on the Storage Gateway file share?

Note the following considerations about the RefreshCache operation:

  • The time that the refresh process takes to complete depends on the number of objects cached on the gateway, and the number of objects added to or removed from the bucket since the last refresh.
  • Refreshing the cache initiates the refresh operation, but the file refresh is a separate process. You can set up refresh cache notifications to get updates on the file refresh process. The refresh-complete notification indicates that the file refresh process is complete. 

Did this article help?

Do you need billing or technical support?