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

extended cache ability #432

Closed
wants to merge 7 commits into from
Closed

extended cache ability #432

wants to merge 7 commits into from

Conversation

KatekovAnton
Copy link

comare checksum of cached image to actual, and reload image if needed. I think is very useful ability! Please let me know if you will merge my changes to original project. Thanks in advance.

@orta
Copy link

orta commented Jun 25, 2013

If you wrap your code in ``` you'll get much easier to read code in this comment ^

@bpoplauschi
Copy link
Member

@KatekovAnton could you please rebase this on top of master so it can be merged? Also, please explain the capabilities you are trying to add and what problems will those address.

@KatekovAnton
Copy link
Author

Hello. Main goal is to cache images using e-tag parameter. SDWebImageManagerCacheDelegate allows you to write your implementation of storing e-tag for cached images. Also it should allows you to make a decision of caching using e-tag for each image individually.

For example my client application have images:
-avatars for my users(png images on remote server),
-images for my products
-ean13 barcode(png image which was generated by some service only using barcode number).

All I know about avatars - is that application should allways check actual version of this kind of image and, if the new one has been spotted, I should remove old one and download a new one. shouldTrackUpdationForUrl will check url, for example if([url rangeOfString:@"avatars/"].range != 0){return YES;} ->should allways track
After it, all i know about my products - is that we will update our images only once a week. So i can implement this logic in shouldTrackUpdationForUrl: else if([url rangeOfString:@"products/"].range != 0) {implement my logic with current date and date of last etag checking}
And, finally, all i know about barcode - is that this image will newer changed, so shouldTrackUpdationForUrl for this case will looks like this: else if([url rangeOfString:@"barcode"].range != 0) {return NO;}

So, if image should be checked by e-tag, SDWebImageManager runs HEAD request to obtain actual e-tag. If it is same - returns image from cache, if not - download new one.

If you think that this functionality is good, i will find time to rebase on top of master.

Sincerely yours,
Katekov Anton

@bpoplauschi bpoplauschi added this to the Future milestone Jun 17, 2014
@mythodeia mythodeia changed the title extexnded cache ability extended cache ability Sep 29, 2015
@dreampiggy
Copy link
Contributor

dreampiggy commented Apr 19, 2018

This PR is about using ETag to identify the same resource. However, this can be done using SDWebImageRefreshCached.

SDWebImageRefreshCached will actually use NSURLRequestUseProtocolCachePolicy. Which is powered by NSURLSession now. It will check all of standard HTTP cache control information. Including:

  • HTTP Cache Control (max-age, only-if-cached, etc)
  • HTTP ETag (If-Match, If-None-Match, etc)

So, actually, if you want to request to the server to response the HTTP standard cache control, you can enable that option now.

Maybe this option is not availble in the time you create this PR...(4 yeas later 😅) But now it should works.

If you want to implement more complicated feature beyond the HTTP standard, welcome to try #2278 feature in 5.x. It allow you to specify custom cache which used by our framework.

Thanks for your contribution. So I just close now. ;)

@dreampiggy dreampiggy closed this Apr 19, 2018
@KatekovAnton
Copy link
Author

Hello. Thank you for the feedback.

You know I remember time when I created it and I think I was a different person lol, so long time ago!

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

Successfully merging this pull request may close these issues.

4 participants