-
-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect and download updated image #52
Comments
Nuke uses NSURLSession's cache management without any modifications. It's most probably that your server sets a really long There at least two ways to adjust that behaviour:
There are also some ways to control it programatically. I've actually written an entire guide on this topic. You might want to check it out. |
I'm using Amazon S3 for storing files. The Etag header is set, but the max-age header is not set (if max-age is what Amazon refers to as Expiry date below): Last Modified: Wed Feb 03 08:00:12 GMT+100 2016 Update: Here's the response headers. See anything that might cause caching problems? Cache-Control:must-revalidate |
|
Nuke also has a memory cache for fast access to processed images. It doesn't have any revalidation mechanisms (yet, it will in Nuke 2), because it gets cleared frequently. It might add some confusion, because images would not get revalidated if they are present in memory cache. I doubt that it's a problem, but just so you know. There isn't anything else that might interfere with cache management in NSURLSession. It should just work if the headers are correct (and seems that they are). |
After upgrading to 2.0 I'm having trouble getting updated images, even though I'm using NSURLRequestCachePolicy.ReloadIgnoringCacheData: let cachePolicy : NSURLRequestCachePolicy = .ReloadIgnoringCacheData Worked fine in the previous version. |
There a separate options for controlling memory cache now: /** Defines constants that can be used to modify the way ImageManager interacts with the memory cache.
*/
public enum ImageRequestMemoryCachePolicy {
/** Return memory cached image corresponding the request. If there is no existing image in the memory cache, the image manager continues with the request.
*/
case ReturnCachedImageElseLoad
/** Reload using ignoring memory cached images. Doesn't affect on-disk caching.
*/
case ReloadIgnoringCachedImage
} public struct ImageRequest {
/** The request memory cache policy. Default value is .ReturnCachedImageElseLoad.
*/
public var memoryCachePolicy = ImageRequestMemoryCachePolicy.ReturnCachedImageElseLoad
} |
|
Oh, ok. thanks! |
That's pretty much the only change in the behaviour in Nuke 2. Everything else should work as expected. |
I'm still having trouble getting updated images unless I set the memoryCachePolicy to ReloadIgnoringCachedImage however. It seems like the Etag is ignored. I have verified that the ETag header is updated when the image is updated on the server and the Cache-Control header is set to "must-revalidate" but this doesn't seem to matter - the old, cached image is used instead. The Last-Modified header is also updated, by the way. Setting the memoryCachePolicy to ReloadIgnoringCachedImage solves the problem, of course, but since this bypasses the cache entirely it doesn't seem like a good solution... |
I probably shouldn't bother you with these questions, since they seem to be more about how NSURLRequest and NSURLCache works. :) |
Yeah, I'm sorry, I can't really help with debugging that :( I would recommend trying to set a If you can't control server side, you can update |
Or just ask on stackoverflow :) |
Actually, yeah, I might have misunderstood how |
|
I'm having trouble getting Nuke to detect images that's been updated on the server - the cached image is used instead. It seems like Nuke doesn't check if the file has been updated on the server by default? Is there a way to force this functionality?
The text was updated successfully, but these errors were encountered: