Image Widget VS. Image Folder Widget caching

  • 1
  • Question
  • Updated 3 years ago
  • Answered
This will be a developer question. 

I am working on the windows IOT for raspberry pi and have a question about the Image Folder Widget. So far i have the image widget caching and displaying. The image folder widget on the other hand doesn't. I know that the image folder widget sends a get request with cb=somenumber?url=thestorageurl 

I can cache and download it but for some reason when i send the header location back i get nothing on the screen. Im doing the exact same as the image widget when sending the headers data back so i was wondering what the difference is between the two. 
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Donna Peplinskie

Donna Peplinskie

  • 7,142 Points 5k badge 2x thumb
The Image Folder Widget works in a similar way as the Image Widget, but provides some extra functionality like filtering by content type or file type. It sends one request to Rise Cache per file in the Storage folder, passing a cb parameter, just as with Image Widget.

When it receives a response from Rise Cache, it checks the Last Modified header and only fires a rise-storage-response event if a file has changed. It will fire one event per changed file, and the added, changed or deleted properties on the response object can be inspected to check if a file has been added, changed or deleted. If the file has not changed, no response will be triggered.

Hope that helps.
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
What format is the date of last modified in. I finally got it to where its now not crashing the app on the image folder widget but all i see is Please Wait while your image is downloaded. 

Edit: I can see that the file is getting to the widget because its calling the web server to show the file but nothing is showing. 
(Edited)
Photo of Donna Peplinskie

Donna Peplinskie

  • 7,142 Points 5k badge 2x thumb
A format like Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT

You can find more details in the RFC2616 spec if you need specifics.

Thx.
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
Thanks I think i found my bottleneck. My file server is not working correctly so I'm having to fix it. 
Photo of Donna Peplinskie

Donna Peplinskie

  • 7,142 Points 5k badge 2x thumb
Good stuff. Finding the problem is half the battle, usually the harder half.
Photo of Donna Peplinskie

Donna Peplinskie

  • 7,142 Points 5k badge 2x thumb
That message will disappear after the slider initializes. But the slider will only start initializing once the rise-storage-response event from the Storage component fires, which in turn only fires once it receives a response from Rise Cache.
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
OK i narrowed it down but this happens in android as well. Im sending the response but as soon as i do i get another request with the same url. Instead of having one request i get two. So here is what i see. The widget send the request and i cache it and save. Then I send the location with all the correct headers and as soon as i send the location i get the same request url again.My question would be am i missing something. Here is the headers that i send or something close.

byte[] headerArray = Encoding.UTF8.GetBytes(                                         
                                          "HTTP/1.1 302 found" +
                                          "\r\n" +
                                          "Date: " + date.ToString("ddd, dd mmm yyyy HH:mm:ss zzz") +
                                          "\r\n" +
                                          "Server: Rise Cache" +
                                          "\r\n" +
                                          "Access-Control-Allow-Origin: *" +
                                          "\r\n" +
                                          "Cache-Control: no-cache" +
                                          "\r\n" +
                                          "Pragma: no-cache" +
                                          "\r\n" +
                                          "Expires: -1" +
                                          "\r\n" +
                                          "Last Modified: " + date.ToString("ddd, dd mmm yyyy HH:mm:ss zzz") +
                                          "\r\n" +
                                          "Location: " + location +
                                          "\r\n" + "\r\n"
                                          );
Photo of Donna Peplinskie

Donna Peplinskie

  • 7,142 Points 5k badge 2x thumb
I really can't say what the problem is without stepping through the code and debugging it. It might be worthwhile for you to set some breakpoints on the rise-storage component (rise-storage.html) to see what's happening.
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
Can you give me the exact headers with location you send back to the widget from your players in the correct order? There is bound to be a reason to why the widgets sends the info again after sending the location back to the widget. I wonder if this happens on the chrome and native player as well. If it does then thats a bug that might need to be cleaned up.  I will keep testing on my end to figure out why but on the IOT app i made this second send crashes it. 
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
Oh and this happens when you have multiple placeholders with an image widget in each. 
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
Ok My issue seemed to be the actual emulator from visual studio. It works fine on the pi2 with no crashing but it still sends double on just the image widget. I can't seemed to get the image folder widget to work though even though I'm using the same process to cache. I can see that the widget is pulling from the fileserver after i send the location but it doesn't change the downloading message. I made sure the widget works if cache wasn't there and it does. Least i made it this far. :)
Photo of Tommy Xie

Tommy Xie

  • 150 Points 100 badge 2x thumb
Who can explain the steps to a new comer how to change the method from Image Widget caching to Image Folder Widget caching? many thanks in advance!