MKNetworkKit icon indicating copy to clipboard operation
MKNetworkKit copied to clipboard

If-None-Match and If-Modified-Since headers never sent

Open ecaste opened this issue 11 years ago • 0 comments

Hi, first of all a big big thank you for your librairie that I've been using for a while... Today I dug into your cache implementation in order to understand exactly what's happened behind the magic.

My issue was : if I didn't use forceReload on GET request, my ressource (image for eg.) didn't get downloaded anymore, only on expiration date (1 day by default in your code).

I found that before queuing a cacheable operation you check this : if(expiryTimeInSeconds <= 0 || forceReload || operationFinished) { [_sharedNetworkQueue addOperation:operation]; }

That means if the expiration date is later than the current date, and I don't want a forceReload my operation is never started...

Perhaps I'm wrong but both ETag and Last-Modified-Date are used for cache validation, and in your implementation you just send these headers when the ressource has expired.

That means if I update my ressource on the server before an expiration date, this ressource will downloaded only when the date expires.

I've commented this line (MKNetworkEngine.h, line 447) and now have the correct behavior (in fact the behavior I wanted to have), with a 304 HTTP Code when my ressource hasn't changed. I don't need anymore to deal with forcereload and the times 2 completion block.

Manu

ecaste avatar Dec 12 '13 17:12 ecaste