Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的应用程序对服务器做了很多请求。很多这些请求都引用了相同的资源。
我想知道我是否应该做些什么来帮助双方节省时间和精力并简单地缓存响应?
默认情况下,请求缓存 60 秒。这可以通过 的cachePolicy:和timeoutInterval:参数来控制NSURLRequest。
cachePolicy:
timeoutInterval:
NSURLRequest
添加:
如果您在 then 中实现connection:willCacheResponse:,您NSURLConnectionDelegate可以看到缓存了哪些响应。
connection:willCacheResponse:
NSURLConnectionDelegate