Code Monkey home page Code Monkey logo

Comments (5)

rs avatar rs commented on August 28, 2024

Your link leads to a 404. Anyway, about your issue, first thing to check is if the URL you are testing is cacheable or not (cache-control header etc.). For instance, http://google.com leads to a 302, which isn't cacheable.

from sdurlcache.

coaic avatar coaic commented on August 28, 2024

What version of iOS are you running. Versions lower than 4, iOS do not call - (NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)request.

from sdurlcache.

gradha avatar gradha commented on August 28, 2024

Ok, it's the headers then. I've changed the URL to another server and it works without problem. Which means I'll have to override the header info somehow because I don't control the remote server. What would be the best place to do this?

Also, the weird thing about the headers is that in these situations the files seem to be getting cached to disk, and iOS seems to be requesting them to later discard them. I tried overridding initWithCoder to force a cache policy of "always" but that didn't work.

I knew about the 3.x iOS since I have an old ipod touch, there the code wasn't being even called.

from sdurlcache.

rs avatar rs commented on August 28, 2024

This is due to the way HTTP caching works : The client may store the response for doing conditional requests even if the response's cache directives don't allow to use the cached data without revalidation. The cache layer (this lib) doesn't control how the request layer (NSURLRequest) handles the cached data.

Because when an UIWebView is used you don't control the cache policy of subsequent NSURLRequests, you can't really force an UIWebView to use the cache even if HTTP server doesn't allow it. One solution though would be to trick NSURLRequest by rewriting the HTTP headers of a cached response before to send it back.

from sdurlcache.

gradha avatar gradha commented on August 28, 2024

Thanks, I'll look into it.

from sdurlcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.