Client-Server DomuS3D uses a distributed cache to minimize network traffic between individual clients and the server.
Reading
When a client needs a file, “F”, located on the database of the server, this is the procedure that is followed:
Td: Timestamp when file “F” was downloaded
Now: Current timestamp
Δ(F): Cache timeout for the file “F”
Tm: Timestamp of last modification of file “F” in Cache
Tms: Timestamp of last modification of the file on the Server
____: Network Access
Writing
When a client needs to modify (or insert) a file “F” located on the database of the server, both the remote copy (located on the server) and the local copy (in the cache) are updated following the write-through method.
Optimizing Network Traffic
Configuring the Cache Timeout
The cache can be optimized through the parameter Δ(F), which represents the cache timeout for the file “F”. This parameter can be set through the registry key CSCacheTimeoutMin, which must be a string in the form of:
<path1>| Δ(<path1>);<path2>| Δ(<path2>);…;*| Δ(*).
For example, by setting CSCacheTimeoutMin=”Bitmap|60;Projects|-1;*|3”, we have:
- all files that contain “Bitmap” in their path have a timeout of 60 minutes;
- all files that contain “Projects” in their path have a timeout of -1 minutes (- > timeout check disabled, constant network access);
- all other files have a timeout of 3 minutes.
In general, as Δ(F) increases, network traffic decreases, and thus the risk of obtaining a file that is not updated is greater (vice-versa: as Δ(F) decreases, network traffic increases).
In the extreme cases:
- if Δ(F)=0, we have maximum network traffic (network is accessed continuously): file will always be updated and correct;
- if Δ(F)=∞, we have minimum network traffic (network is accessed only once): when file is changed on the server, the client will not have the modification.
Knowing the update frequency of a file in advance allows us to set the optimal Δ(F) value, which is equal to its inverse. In particular, if F is never modified after its initial creation, then the optimal Δ(F) value is equal to ∞. If the update frequency of a file is unknown, we tend to use a high value of Δ(F) when dealing with slower networks and low values of Δ(F) with faster networks.
Prefetching and Emptying of Cache
It is possible to prefetch the cache using the dedicated command in the menu Server -> Cache -> Prefetch. This allows you to preload data in the cache when the network is not experiencing heavy traffic or when a delay would not be an issue, making sure you have the highest speeds in the following period.
It is also possible to empty the cache using the command in the menu Server -> Cache -> Empty, so that you can recover disk space, forcing files on the server to be downloaded the next time it is accessed.
During the prefetch of the cache, Δ(F)=0 for all files regardless of the value specified during setup. This allows you to set Δ(F)=∞ and then use the prefetch/empty commands to manually manage the cache, extremely useful when dealing with very slow networks.
Examples
Fast Networks: When dealing with high-speed networks, you can set Δ(F)=∞ for all files that never undergo modifications and Δ(F)=0 for all other files. For example, if we know that the catalogue for a certain manufacturer, after its initial upload, will never be modified, we can set CSCacheTimeoutMin=”Bitmap\manufacturername|999999;*|0”.
Slow Networks: When dealing with slightly slower networks, it is best to set Δ(F)=∞ for all files that never undergo modifications and Δ(F) roughly equal to the inverse of the frequency with which all other files are modified. If a user realizes that they do not have an updated file, they can refresh it running the "Refresh" command.
This article is valid for DomuS3D® 2018 and later