Skip to content
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

Allow creating a ASPINRemoteImageDownloader that ignores caches #12

Conversation

plarson
Copy link
Contributor

@plarson plarson commented Apr 14, 2017

Moving this change from facebookarchive/AsyncDisplayKit#3257

@CLAassistant
Copy link

CLAassistant commented Apr 14, 2017

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ Adlai-Holler
✅ garrettmoon
❌ Phil Larson


Phil Larson seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@garrettmoon
Copy link
Member

@plarson to continue the conversation here, would it be better to expose the sessionManager instead of adding this option?

@plarson
Copy link
Contributor Author

plarson commented Apr 14, 2017

@garrettmoon Exposing session manager would be helpful for adding custom HTTP headers.

For the caching issue, it seems to me that the best way is specifying PINRemoteImageManagerDownloadOptionsIgnoreCache?

It's checked in -[PINRemoteImageManager objectForURL:processorKey:key:options:completion:], which isn't related to the sessionManager. I see it as a race condition issue like checking if a file exists before opening it with NSFileManager instead of simply trying to open it and let it fail.

Clearing the cache for a URL before setting it on ASNetworkImageNode is technically a tiny performance hit since the app has to do the work to cache/clear an image that I am trying to always load from the network.

If the only way is removing the URL explicitly from the cache, then maybe ASImageCacheProtocol should be updated to have a method such as -(void)clearFetchedImageFromCacheWithURL:(NSURL *)URL includingDiskCache:(BOOL)includingDiskCache ?

@plarson
Copy link
Contributor Author

plarson commented Apr 14, 2017

In my opinion it might be options/flags added to ASNetworkImageNode that flows through ASImageDownloaderProtocol and -[ASImageDownloaderProtocol downloadImageWithURL:callbackQueue:downloadProgress:completion:] would change to accept an options argument that is analogous to PINRemoteImageManagerDownloadOptions. However, that would be a bigger change.

@ghost
Copy link

ghost commented Apr 26, 2017

1 Warning
⚠️ Any source code changes should have an entry in CHANGELOG.md or have #trivial in their title.

Generated by 🚫 Danger

@appleguy
Copy link
Member

appleguy commented Oct 8, 2017

I'm in favor of providing more control to users of ASNetworkImageNode, in terms of caching behavior. So a config object / struct should be considered, although we might want to have it set at a class level rather than an instance level.

Among the parameters that would be useful to configure are properties on the PINDiskCache, like byteLimit. But also, I definitely agree we should make it easier to decouple from these frameworks and run without caching, etc.

@appleguy
Copy link
Member

@garrettmoon any thoughts on the best way to support this?

@garrettmoon
Copy link
Member

I feel like the underlying issue is that it's not straightforward to subclass ASPINRemoteImageManager. If we could make that easier we'd be able to support many more scenarios?

@appleguy
Copy link
Member

@garrettmoon Yes, that could be helpful. I think there is probably a small number of knobs that should exist without subclassing, though; in particular, if there were only one, turning off the cache is likely to be the most common. I've seen a number of cases where PINCache is linked for other usages in an app, but a disk cache is not desired (or in fact allowed, due to it not handling server-specified expiry policies).

Any more specific guidance for the author of this PR? If you have thoughts on how we could make the subclassing option easy and clean and allow cache disabling as part of that, it would definitely be a step forward from today.

@Adlai-Holler
Copy link
Member

Note: #747 provides a great place to specify your custom image manager.

@nguyenhuy
Copy link
Member

nguyenhuy commented Sep 21, 2018

Note: #1124 makes it easy to specify a custom, preconfiged image manager.

@nguyenhuy
Copy link
Member

Based on the last 2 comments, I suppose we can close this old PR. Please feel free to reopen/open a new one if need to. Thank you all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants