omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Neso

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 8
    • Best 0
    • Controversial 0
    • Groups 0

    Neso

    @Neso

    0
    Reputation
    630
    Profile views
    8
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Neso Unfollow Follow

    Latest posts made by Neso

    • RE: Questions about Webview

      @JonB

      I did some searches. Do you think this and this are relevant? Also maybe cachedresponseforrquest?

      I think the key is to find a way making nsrequest cache images. I ran share_cache.currentMemoryUsage() during the site loading. The memory usage is very small.

      posted in Pythonista
      Neso
      Neso
    • RE: Questions about Webview

      @JonB

      I would like to force writing cache to the disk so I set memorycapacity as 0 (don’t know whether this is right). The disk usage of cache is about 110k. Almost no change after several times of reloading the site.

      Do cached requests have to be in the same domain with “NSURL”? There is a redirect during site loading. Wondering whether this is relevant.

      Requests have the same domain. The format is like:

      http://[fixed domain]/xxx.png?version=x.x

      The modification date of the cache files changes so cache is actually affected. However don't know why large images do not get cached.

      posted in Pythonista
      Neso
      Neso
    • RE: Questions about Webview

      @JonB

      Thank you very much. Now I can finally locate the cache folder. There are three files: cache.db, cache.db-wal and cache.db-shm. So the cache is initialized successfully. I ran the code you provided. The size of these files are not changed. I guess the cache has not been used?

      The website is a browser gaming site. It will download resources (mainly image) during start-up. I am trying to figure out a way to avoid repeated downloading.

      posted in Pythonista
      Neso
      Neso
    • RE: Questions about Webview

      @mikael

      yep, I tried both ways. The strange thing is, I cannot find the cache directory in either cases. Answers from stackoverflow tell that the cache directory is located in “Library/Cache” but no directory or file was there. I did some searches using stash however cannot find anything related. So it is possible that cache is not created from the very beginning.

      My code structure is like:

      NSURLCache = ObjCClass('NSURLCache')
      shared_cache = NSURLCache.alloc().initWithMemoryCapacity_diskCapacity_diskPath_(100*1024*1024,1200*1024*1024,'kc')
      NSURLCache.setSharedURLCache_(shared_cache)
      
      w, h = ui.get_screen_size()
      
      v = ui.View(background_color='black')
      wv =ui.WebView()
      
      ......
      
      

      Missing anything?

      posted in Pythonista
      Neso
      Neso
    • RE: Questions about Webview

      @JonB

      No luck. I tried

      os.path.abspath(os.path.dirname(__file__))+'/kc’
      
      

      No file was written to the directory.

      posted in Pythonista
      Neso
      Neso
    • RE: Questions about Webview

      @JonB

      Thank you.
      I have made some searches and constructed a piece of code.

      NSURLCache = ObjCClass('NSURLCache')
      shared_cache = NSURLCache.alloc().initWithMemoryCapacity_diskCapacity_diskPath_(100*1024*1024,500*1024*1024,"kc")
      NSURLCache.setSharedURLCache_(shared_cache)
      

      Tested. Look like it does not preserve and reuse caches. Is there any mistake?

      posted in Pythonista
      Neso
      Neso
    • RE: Questions about Webview

      @mikael
      Thanks for your input. According to your case, cache is removed when quitting Pythonista. I would like to know an approach to keep cache (to a specific size for best) even after closing Pythonista.

      posted in Pythonista
      Neso
      Neso
    • Questions about Webview

      Hello,
      I am building a webview to present a specific website. There are some questions:

      1. Is it possible to have persistent web cache between sessions? The webview is for just one site so keeping cache could save traffic and time downloading resources.

      2. I make webview a subview of a UI View and present the UI view in landscape fullscreen. Since I hide title bar, I can only double-finger swipe down to close. However after I close the view, the webview seems to be still running in the background. Any way to completely close it except for closing Pythonista?

      Any help will be welcomed.
      Thanks.

      posted in Pythonista
      Neso
      Neso