NSURLCache and ETags

前端 未结 1 727
夕颜
夕颜 2020-12-09 10:42

Does NSURLCache transparently handle ETags received by server?

I mean: does it automatically store ETags for each URL request and then send the appropri

相关标签:
1条回答
  • 2020-12-09 11:08

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

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

    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.

    0 讨论(0)
提交回复
热议问题