Permalink
Browse files

Change RCTImageLoader's Cache System to default NSURLRequest's cache …

…system

Summary:
Before this PR, ```RCTImageLodaer```'s Cache was too big(200MB on disk) and It doesn't work with HTTP Cache-Control header. So to provide dynamic image, the users must have to add random value on url( ex. adding current date) to avoid cache.

So I change that cache system to default ```NSURLRequest```'s cache system, which is well-working with HTTP specs. As the discussion on this issue #7571 , making custom cache policy processor is not ready yet and useless, over-tech things, I think.

Even we have no plan about image cache system(or would change plan later), before having a nice plan, I think we should let user use image module with common HTTP Specs.

So I remove custom ```NSURLCache```, and make logic like below,

1. try fetch image,

2. on response, get ```Date``` on response's header and make ```cacheKey``` with ```Date```.
> (why? because if ```NSURLRequest```'s response was cached, the response's ```Date``` header dosen't change.)

3. find decoded imag
Closes #8235

Reviewed By: bnham

Differential Revision: D3469086

Pulled By: javache

fbshipit-source-id: 35a5552cda6e6c367481020bbf3c28eb4a9d0207
  • Loading branch information...
skatpgusskat authored and Facebook Github Bot 2 committed Jul 21, 2016
1 parent 5903949 commit 631785f2ee852c4621eed81053a63166887071e6
Showing with 149 additions and 181 deletions.
  1. +3 −0 Libraries/Image/RCTImageLoader.h
  2. +146 −181 Libraries/Image/RCTImageLoader.m
@@ -176,6 +176,9 @@ typedef dispatch_block_t RCTImageLoaderCancellationBlock;
* Decode an image from the data object. The method should call the
* completionHandler when the decoding operation has finished. The method
* should also return a cancellation block, if applicable.
*
* If you provide a custom image decoder, you most implement scheduling yourself,
* to avoid decoding large amounts of images at the same time.
*/
- (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)imageData
size:(CGSize)size
Oops, something went wrong.

0 comments on commit 631785f

Please sign in to comment.