llyouss / PAWebView

An component WebView for iOS base on WKWebView
MIT License
183 stars 32 forks source link

缓存开关openCache并没有使用到,开启后没有缓存效果 #9

Open DingMaster opened 6 years ago

llyouss commented 6 years ago

新版已弃用,使用 NSURLRequest 缓存策略;参考代码 //加载网页 [webView loadRequestURL:[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.sina.cn"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0f]];

//缓存沿用了 NSURLRequest 的缓存机制,用户可以自定义设置; typedef NS_ENUM(NSUInteger, NSURLRequestCachePolicy) { NSURLRequestUseProtocolCachePolicy = 0, //默认的缓存策略

NSURLRequestReloadIgnoringLocalCacheData = 1, //忽略缓存,从服务端加载数据;
NSURLRequestReloadIgnoringLocalAndRemoteCacheData = 4, // Unimplemented
NSURLRequestReloadIgnoringCacheData = NSURLRequestReloadIgnoringLocalCacheData,

NSURLRequestReturnCacheDataElseLoad = 2,
NSURLRequestReturnCacheDataDontLoad = 3,

NSURLRequestReloadRevalidatingCacheData = 5, // Unimplemented

};

myGitHubHehe commented 5 years ago

打开一个网页,再关闭再打开别的网页,在刚开始的时候会显示上次打开的网页的页面,闪一下之后,才会加载现在的网页