--------------------------------------------------------------------
user 1 使用 iPod 1 登录,修改,保存
user 2 使用 iPod 1 登录,user2头像-->显示
user 1 使用 iPod 1 登录,user1头像-->显示(旧的)
user 1 使用 iPod 2 登录,user1头像-->显示(新的)
user 1 使用 iPod 1 登录,user1头像-->显示(旧的)
我的做法是,不管哪个用户登录都是用同一个名字保存头像的,而在一个用户登录的时候会把上一个用户的头像remove了再重新抓取当前用户的头像
save的
---------------------------------------------------------------------------------
问题反复验证还是这样,后来调试加猜测,应该是本地或是网络哪里做了cache。所以就回头看了我调用老大写的网络请求的代码,发现他用了cache。
大脑一醒,就是这地方了。呵呵
现在先看一下NSURLRequest的 url 缓存策略:
------------------------------------------------------------------------------------
requestWithURL:cachePolicy:timeoutInterval:
1:NSURLRequestUseProtocolCachePolicy
This flag will use the underlying protocol’s caching mechanism if the
protocol
supports it.
基础策略
2:NSURLRequestReloadIgnoringLocalCacheData
This flag specifies that the local cached copy of the resource that is
about to be
downloaded must be disregarded and the remote cache policy must be
effective.
If there is a local copy of the resource, managed by the framework
itself, it will be
ignored.
忽略本地缓存
3:NSURLRequestReturnCacheDataElseLoad
This flag specifies that the cached data must be used before
attempting to load the
data from the original source. The cached data could be protocol-based
cached or
locally cached. If there is no cached data, the data will be
downloaded from the
original source.
首先使用缓存,如果没有本地缓存,才从原地址下载
4:NSURLRequestReturnCacheDataDontLoad
This flag specifies that only the local cached data must be used. If
the data has not
been cached, the request will fail. This is a great flag to use
whenever your application
wants to perform operations in offline mode (such as the Offline Mode
in
web browsers).
使用本地缓存,从不下载,如果本地没有缓存,则请求失败。此策略多用于离线操作
5:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
This flag disregards any type of caching involved in the process,
local and remote,
and always attempts to download the data from the original source.
无视任何的缓存策略,无论是本地的还是远程的,总是从原地址重新下载
6:NSURLRequestReloadRevalidatingCacheData
This flag specifies that the original source of data must validate the
local cache (if
any) before an attempt is made to download the data from the original
source. If
there is a copy of the original source cached locally and the remote
source specifies
that the cached data is valid, the data won’t be downloaded again. In
any other
case, the data will be downloaded from the original source.
如果本地缓存是有效的则不下载。其他任何情况都从原地址重新下载
------------------------------------------------------------------------------
上面这一段英文部分在NSURLRequest的.h文件都有的,而我所以能看懂大概意思,但限于E文的水平问题,所以只能到网上去找中文部分来添加上
来,生怕自己出错。原文参考http://o0o0o0o.iteye.com/blog/1326713