当前位置: 首页 > 工具软件 > Ftp Dot Net > 使用案例 >

Dot Net下开发FTP存在的缓存策略问题

仉宪
2023-12-01

用dotnet的类库FtpWebRequest 开发应用已经不是什么新鲜话题。

在这里说的是一个怪问题,小组总共四人,两人下载文件正常,两人总是从缓存中下载文件(即便文件已经更新)。显然这是本地计算机的缓存策略在作怪,可是大家的开发环境基本一致为什么会出现不同的结果呢?

查阅了一下msdn:

Only content received using the DownloadFile command is cached.

The following table describes the effects of FTP caching policies on FtpWebRequest.

Policy

Effect

Returns the cached resource if the resource is fresh, the content length is accurate, and the expiration, modification, and content length attributes are present.

Returns the resource from the server.

Returns the cached resource if the content length is present and matches the entry size; otherwise, throws a WebException.

Returns the cached resource if the content length is provided and matches the entry size; otherwise, the resource is downloaded from the server and is returned to the caller.

Returns the cached resource if the timestamp of the cached resource is the same as the time stamp of the resource on the server; otherwise, the resource is downloaded from the server, stored in the cache, and returned to the caller.

Downloads the resource from the server, stores it in the cache, and returns the resource to the caller.

If a cached resource exists, it is deleted. The resource is downloaded from the server and is returned to the caller.

 

在ftp操作之前强制设置了一下:

FtpWebRequest.DefaultCachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.Reload);

一切OK了。估计是dotnet framework配置文件不一样导致了这个问题,配置文件是什么样的,还得继续研究....

转载于:https://www.cnblogs.com/moon2bird/archive/2008/12/29/1364706.html

 类似资料: