How can I automate the RefreshCache operation on Storage Gateway?

3 minute read

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. Setting the TTL to a low value 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. Choose Actions, and then choose Edit File Share Settings.
  5. For Automated cache refresh from S3 after, select Set refresh interval.
  6. Set the time in days, hours, and minutes to refresh the file share's cache using TTL.
  7. Choose Save.

To automate the RefreshCache operation using the Storage Gateway API, use the UpdateNFSFileShare API call or the UpdateSMBFileShare API call. For both API calls, you need to 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 following:
    • Number of objects cached on the gateway.
    • Number of objects added to or removed from the bucket since the last refresh.
  • Refreshing the cache initiates the refresh operation. However, 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.

AWS OFFICIALUpdated 2 years ago