Cache files when offline RRS feed

  • Question

  • I would like to store several images (roughly 2mb of gifs) for use when user is not connected.  I have the piece that checks for a connection.  What I would like to do is simply store the images locally and if they are not connected, than use the stored images until they have a connection again, similar to caching.   How can I accomplish this with WinJS?

    Saturday, January 17, 2015 3:13 PM


All replies

  • Hi ,

    Switch the URL according to network status.

    Hope that helps
    Please don't forget to up vote answers you like or which help you and mark one(s) which answer your question.


    M Prabath Maduranga Peiris
    Microsoft Partner  and MSP/MSA
    Blogs : prabathsl.blogspot.com

    Saturday, January 17, 2015 3:55 PM
  • Ok.  But how do I obtain the new url?  How do I send them to local storage using javascript?
    Saturday, January 17, 2015 5:11 PM
  • This is not very hard. 

    Here is the flow i would suggest:

    1) CHECK-CONNECTION [Ping-Test? | System-Information? ]
    2) ONLINE: Download Picture to local Folder. Use this image as "CSS/Background-Image" or "IMG/Src"-Source.
    2) OFFLINE: Use the local-Folder file as CSS/Background-Image" or "IMG/Src"-Source.

    © 2015 Thomas Roskop

    Saturday, January 17, 2015 6:37 PM
  • This is exactly what I want to do.  It is very simple.  Windows 8 app, Javascript, grab image files while online and save to local folder.   Use local folder when offline.   Would you recommend using the POST method to send to local folder?  What about a cache manifest file?

    Saturday, January 17, 2015 7:55 PM
  • The HTTP-Standart says that a POST-Message changes something on the server. is this happening in your case? If not, than you should use GET instead to downloaad the file.

    Here is the way to access the images from HTML/css code: http://msdn.microsoft.com/en-us/library/windows/apps/Hh781229(v=win.10).aspx

    And here is how to work with the localFolder: http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localfolder.aspx?cs-save-lang=1&cs-lang=javascript#code-snippet-1

    Good Luck!

    © 2015 Thomas Roskop
    Germany // Deutschland

    • Marked as answer by hxnwx Saturday, January 17, 2015 8:28 PM
    Saturday, January 17, 2015 8:20 PM
  • Not changing anything, so I will use GET.  Thanks for your help.  This is what I needed.

    Saturday, January 17, 2015 8:28 PM