Help with Deck Of Cards API and startWebRequest

Hi everyone!

I am tinkering around with the Deck Of Cards API and I built a simple app (link below), which is meant to create a shuffled deck of cards, then reveal a button that the user can push to show the next card in the deck.

When I run the app it calls getDeck, which uses startWebRequest to get a deck of cards, initialize a global variable with the deck ID, then reveals a button for the user to click. This works as expected.

When I click the button the event handler uses the deck ID (stored in the global variable) and startWebRequest to retrieve a card and show the image of that card. This also works as expected.

However, when I click the button a second time it just returns the same card while I expect it to retrieve and show a new card.

When I paste the card-draw url (copied from my console.log statement with the current deck ID) into my browser it behaves exactly as I expect: it gives a different card and decrements the “remaining” member by one. When I reload, it again gives a new card and decrements “remaining” as expected.

Why is my event handler not actually retrieving the next card?

Thanks in advance!

This morning I checked the network activity in my browser’s developer tools and discovered this:

It makes sense that app lab is wrapping the request URL in its own url, but I noticed the status code 200 is accompanied by the (from disk cache) note, which seems to be why a new card is not retrieved. I also noticed Cache-Control: max-age=60, public. Sure enough, if I wait a minute and click the button in my app a new card is retrieved and shown.

So, now I am on the hunt to figure out how to control the caching of the response from my web request. Any suggestions?

Sigh. I was able to add a random parameter to my URL like this:

var url = “” + deckID + “/draw/?random=”+randomNumber(0,255);

This works since the URL changes it is not found in the cache and a new request is made, but it is not at all elegant.

Any insights into how to control the caching from within App Lab would be greatly appreciated.