Our users are complaining about very slow network performance when opening or saving files to a network shared folder in Windows. When a user opens a shared folder via a UNC path, or via a drive letter (if the shared folder is mapped as a network drive), its contents are displayed only in 10-60 seconds. When creating new files in a network folder, they are also not displayed immediately, but with a long delay after 3-4 minutes (even if you update the folder contents with the
F5 key). However, if you manually specify the full file name via a UNC path (
\\lon-file-srv1\public\new_file.docx), it will open, although it won’t be visible in the File Explorer.
Windows uses a special Network Redirector component when access shared files and other network resources on remote computers. Starting with SMB v2.x (see the table with Server Message Block protocol versions), the Network Redirector uses a caching mechanism when accessing shared folders and files over the network. This reduces the traffic and the number of SMB requests between the client and the server (especially effective on in slow and unreliable networks). By default, this cache is cleared every 10 seconds.
If you are experiencing slow access to a network share on a Windows client device, you can try disabling the SMB metadata caching on the client side or in the shared folder settings.
You can disable SMB caching in the shared folder settings. Open the properties of the shared folder, and go to the Sharing tab -> Advanced Sharing -> Caching. Select the second option “No files or programs from the shared folder are available offline”.
Or use the PowerShell command:
Set-SMBShare -Name MySharedDocs -CachingMode None
This will disable both caching and offline access to this shared folder (see the article on using offline files in Windows).
There are three registry parameters that manage network shared folder cache settings on the SMB client side. Microsoft states that the default values for these registry options provide the best performance for most environments. The SMB cache settings are located under the registry key HKLM\System\CurrentControlSet\Services\LanmanWorkstation\Parameters.
- DirectoryCacheLifetime is the lifetime of the shared folder metadata cache (10 seconds by default);
- FileNotFoundCacheLifetime – “File not found” response cache (5 seconds);
- FileInfoCacheLifetime – the time of keeping the cache with the file info (10 seconds).
By default, the cache lifetime for an SMB share folder is only 10 seconds. When a client refresh the contents of a shared folder, the result of the last update is stored by the client for 10 seconds. When accessing this network share, all applications first try to use this cache.
In some cases, the mechanism for caching data in SMB folders doesn’t work correctly (most often this happens with network folders/drives containing thousands of files and folders). In this case, users may experience significant delays when opening, viewing, and creating files in shared folders.
You can disable caching for SMB folders. To do this, create a new DWORD parameter under the HKLM\System\CurrentControlSet\Services\LanmanWorkstation\Parameters registry key with the name DirectoryCacheLifetime and a value of 0. Also set the values of the FileInfoCacheLifetime and FileNotFoundCacheLifetime parameters to 0. You can create this registry parameters using
regedit.exe or with the New-ItemProperty PowerShell cmdlet:
$Name1 = "DirectoryCacheLifetime"
$Name2 = "FileInfoCacheLifetime"
$Name3 = "FileNotFoundCacheLifetime"
New-ItemProperty -Path $regpath -Name DirectoryCacheLifetime -Value 0 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $regpath -Name FileInfoCacheLifetime -Value 0 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $regpath -Name FileNotFoundCacheLifetime -Value 0 -PropertyType DWORD -Force | Out-Null
You must restart your computer for the settings to take effect. If these parameters need to be applied to multiple domain computers, you can use the GPO to deploy the registry settings.
You can also use the Set-SmbClientConfiguration cmdlet to fine-tune the SMB client:
Set-SmbClientConfiguration -DirectoryCacheLifetime 0
Set-SmbClientConfiguration -FileInfoCacheLifetime 0
Set-SmbClientConfiguration -FileNotFoundCacheLifetime 0
You can list the current caching settings for the Windows SMB client with PowerShell:
Get-SmbClientConfiguration| select *cache*
DirectoryCacheEntriesMax : 16 DirectoryCacheEntrySizeMax : 65536 DirectoryCacheLifetime : 0 FileInfoCacheEntriesMax : 64 FileInfoCacheLifetime : 0 FileNotFoundCacheEntriesMax : 128 FileNotFoundCacheLifetime : 0
After that, all changes in the shared will be immediately displayed on the client (the contents of the folder are refreshed each time it is accessed and the local cache is not used).
There are several other reasons for poor network performance of shared folders, or when the contents of folders may appear slowly:
- Enabling the “Access-based Enumeration (ABE)” option in the shared folder settings can lead to a slow update of the list of files in a shared folder with a large number of objects;
- You may experience slow network speed on Hyper-V virtual machines running on Windows Server 2019 (compared to Windows Server 2016/2012R2);
- Try to disable the legacy NetBIOS protocol in the properties of your TCP/IPv4 connection on the domain-joined devices (
ncpa.cpl-> open the network adapter’s TCP/IPv4 settings and select Disable NetBIOS over TCPIP on the WINS tab);
- Try resetting the network and TCP/IP stack settings on the Windows client device. On Windows 10+, you can use the option Network Reset in Settings panel or use the command:
netsh int ip reset