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

用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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值