NSURLCache和ETags [英] NSURLCache and ETags

查看:119
本文介绍了NSURLCache和ETags的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NSURLCache是​​否透明地处理服务器收到的ETag?我的意思是:它是否为每个URL请求自动存储ETag,然后在提交对同一URL的请求时发送相应的IF-None-Match?
或者我必须自己管理吗?

Does NSURLCache transparently handles ETags received by server? I mean: does it automatically store ETags for each URL request and then send the appropriate IF-None-Match when a request to the same URL is submitted? Or do I have to manage it by myself?

推荐答案

是的,如果你设置它的缓存,它会透明地处理它模式:

yes it does handle it transparently if you set its cache mode:

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]
                                                           cachePolicy: NSURLRequestUseProtocolCachePolicy
                                                       timeoutInterval:60];

注意:您根本无法看到请求中的标头,并且如果返回304响应服务器只能看到从缓存中透明加载的200响应。

note: you cannot see the header in the request at all and if a 304 response is returned by the server you will only see the 200 response that it transparently loaded from the cache.

这篇关于NSURLCache和ETags的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆