用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

Default

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

BypassCache

Returns the resource from the server.

CacheOnly

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

CacheIfAvailable

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.

Revalidate

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.

Reload

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

NoCacheNoStore

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配置文件不一样导致了这个问题,配置文件是什么样的,还得继续研究....

posted on 2008-12-29 18:02  一云  阅读(451)  评论(0编辑  收藏  举报