You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have an image URL that's unique generated every time we call an end point, the URL is short living and expires in about 10 mins. When I use the af_setImage function, the default identifier is generated base on the request.absoluteURL, which does not work well in this case. I'm looking at KIngfisher library where they have option to set the custom cache key like
let resource = ImageResource(downloadURL:imageURL, cacheKey: customKey) imageView.kf.setImage(with: resource ....
I would think AlamofireImage can do something similar by replacing the urlRequest parameter with a resource object that wraps around download url and cache key?
The text was updated successfully, but these errors were encountered:
Workaround:
Instead of doing a GET request to fetch the image, do a POST request.
Remove the short-lived params from the query string and pass them as POST params.
Use af_setImage(withURLRequest: ..) instead of af_setImage(withURL: ..).
Your URL with not change and the cache will work.
@cnoon, we support this at the cache level (appending an additional identifier), seems like we could just plumb it through to the UIImageView extension? However, that API is getting rather out of hand. Perhaps something of a refactor would be advised?
Yep, agreed @jshier. We could certainly append the key for now and then rethink these APIs in the next major release. I'll see what I can put together here.
I just spoke with @jshier about the complexity here and it's a bit too involved to do properly in the AFI 3.x APIs. We've put together a fairly detailed card into our Trello backlog to pick this up when we start on the AFI4 changes. I'm going to close this issue out for now and link it to that milestone. We'll re-open once we get closer to starting that work.
We have an image URL that's unique generated every time we call an end point, the URL is short living and expires in about 10 mins. When I use the af_setImage function, the default identifier is generated base on the request.absoluteURL, which does not work well in this case. I'm looking at KIngfisher library where they have option to set the custom cache key like
let resource = ImageResource(downloadURL:imageURL, cacheKey: customKey)
imageView.kf.setImage(with: resource ....
I would think AlamofireImage can do something similar by replacing the urlRequest parameter with a resource object that wraps around download url and cache key?
The text was updated successfully, but these errors were encountered: