Cache handling according to RFC 7232

This commit is contained in:
relikd
2019-08-21 10:42:02 +02:00
parent e7dbfa5770
commit eb32ca9617
6 changed files with 122 additions and 4 deletions

View File

@@ -54,7 +54,10 @@
- (void)setSucessfulWithResponse:(NSHTTPURLResponse*)response {
self.errorCount = 0; // reset counter
NSDictionary *header = [response allHeaderFields];
[self setEtag:header[@"Etag"] modified:header[@"Date"]]; // @"Expires", @"Last-Modified"
if (response.statusCode != 304) { // not all servers set etag / modified when returning 304
[self setEtag:header[@"Etag"] modified:header[@"Last-Modified"]];
[self setUrlIfChanged:response.URL.absoluteString];
}
[self scheduleNow:self.refresh];
}