0
這裏是非常簡單的電話我做:NSURLConnectionDelegate的連接:willCacheResponse:隨機稱爲
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:500];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
[connection start];
我嘗試在谷歌找到2頁隨機PDF格式的URL(搜索 「TRUC文件類型:PDF」):
A) NSString *urlString = @"http://www.eatletruc.com/letruc.menu0411.pdf";
B) NSString *urlString = @"http://www.botruc.com/boat-specs/C-Truc-7.pdf";
他們都有類似的報頭(使用allHeaderFields在連接:didReceiveResponse :):
A)
"Accept-Ranges" = bytes;
Connection = "Keep-Alive";
"Content-Length" = 2641705;
"Content-Type" = "application/pdf";
Date = "Thu, 11 Apr 2013 08:53:39 GMT";
Etag = "\"19a7b55-284f29-4a0a5e94ae1a7\"";
"Keep-Alive" = "timeout=5, max=100";
"Last-Modified" = "Mon, 11 Apr 2011 15:05:50 GMT";
Server = Apache;
B)
"Accept-Ranges" = bytes;
Connection = "Keep-Alive";
"Content-Length" = 343793;
"Content-Type" = "application/pdf";
Date = "Thu, 11 Apr 2013 08:55:38 GMT";
Etag = "\"b6864a-53ef1-49400c1d95800\"";
"Keep-Alive" = "timeout=5, max=100";
"Last-Modified" = "Mon, 01 Nov 2010 17:01:20 GMT";
Server = "Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635";
但連接:willCacheResponse:只要求網址B.我發現只有在Cache.db SQLite數據庫URL B中。
爲什麼url不被緩存?