Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8920019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:09:44+00:00 2026-06-15T06:09:44+00:00

Am facing thi really unusual problem with MKNetworkKit caching. In simple word’s the problem

  • 0

Am facing thi really unusual problem with MKNetworkKit caching. In simple word’s the problem is that “It is not working”..!

I have created a simple test project which has the problem. The project does nothing, but just makes a simple GET request to http://where.yahooapis.com/ to fetch the the address or information for a city name. The response, is supposed to be chached the first time you run it and from second time the completion handler will be called twice, once with cached response and again with the fetched response. as you can see below, which is taken from http://blog.mugunthkumar.com/coding/ios-tutorial-image-cache-and-loading-thumbnails-using-mknetworkkit/

MKNetworkKit calls the SAME completion handler with cached data if you
are making the call for the second time. When the network connectivity
is proper, MKNetworkKit calls your completion handler twice. First
with the cached data and again after fetching the latest data from
server.

Well, the unusual thing is, I run the app, it didn’t cache, I again ran the app, it again didn’t cache, after some random runs suddenly the caching started working. I deleted the app and run it again, the cache wont work till some random runs and problem repeats..!

FYI, I have used the latest MKNetworkkit downloaded from GIT.

Am not sure whether it is some problem with my code, or a bug with MKNetworkKit itself. So please go through with the code, and let me know if its me or the MKNetworkKit that’s causing this problem.

Here is the link to download the sample project [https://www.box.com/s/tsfw3z0avpti051xbyhv]4

Thank, in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:09:45+00:00Added an answer on June 15, 2026 at 6:09 am

    Finally, I am able to figure it out..! So here is what happens , during caching,

    MKNetworkKit caching is super light-weight and it caches your
    responses in a NSMutableDictionary. Doesn’t that lead to high memory
    usage? Yes. of-course, but MKNetworkKit is clever. It observes the
    UIApplicationDidReceiveMemoryWarningNotification and flushes the
    dictionary to disk. The next time you make a request to the cached
    URL, the cached data is brought back to memory. So in-effect, it has a
    in-memory cache and disk cache and uses a least recently used
    algorithm to flush items to disk. The MKNetworkEngine class has
    methods that can be over-ridden to control the cache cost.

    So what was, happening is, that when I ran the app the first time, the response got cached in “memory” in and not in the “disk”. When I cold started the app, the response which was cached earlier was never transferred to “disk” from “memory”. (That was the reason why, there wasn’t even a cached file in in the application’s cache directory..!) Hence, the successBlock was never getting called twice, with a cached response, because, there wasn’t one..!

    To get over this problem, its just overriding one function with just one line of code…!

    - (int) cacheMemoryCost
    {
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing a really strange problem that has me smoked. I have a fairly
I facing very huge problem now, that is I have usercontrol (created by me)
Im facing the problem that i am not able to get the chart like
I´m facing this problem: I have a Button that works like a WrapPanel using
I facing a weird problem here. I already have a simple try-out for jquery
Facing a problem, it seems my data stored in SQL Server does not stored
im facing a problem where i need some advice. I want to have a
I'm facing a problem here : I have two tables : A users table
Actually, I am facing a problem in Android. I am creating an application that
Im facing a problem. I have a listing page in which i list all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.