Monday, January 21, 2013

iOS 6 caching Ajax data

Wow, it's been a crazy 24 hours for MonsterCache development.  Kent and Joshua had found a few bugs once they got their iOS versions of the app.  Sunday morning I got a chance to work on them and fixed most of them!  So I sent Kent a new version with:
  • sound for caught monster fixed in iOS
  • restyled popup windows
  • splash screens
  • badge images now showing up
  • "Recenter Map" button
I was very excited about the progress!  But there was one issue I couldn't figure out.  He said that each time he logged in, it was resetting his nets and coins back to their original values, even after he had used some nets and coins.  This was a new account for him, so every time he logged in, it just said 100 coins and 5 nets.  I asked him to make sure he did a Force Quit and try once more and he said it does same thing after many Force Quits.  So then I was depressed because this sounded like a major problem.

All that data is stored in window.sessionstorage, so I thought something was wrong with that, and that the values wouldn't overwrite. I've never heard of an issue like that. I just kept searching and couldn't find anything. I *thought* I had not seen this in the ios simulator in XCode.  But I think I didn't see it before because I occasionally have to do a "Reset content and settings" which must clear the cache. Or I just didn't notice.  Luckily I tried one more time to duplicate in the simulator before sending a version with some little storage tests to Kent and I was able to duplicate it.  I bought a net, logged out, logged in, and it showed the old numbers.

From there, I just had to put in a couple of alert() boxes to discover that the data coming back from the Ajax login call was incorrect.  The storage wasn't the problem, the data coming back from the login call was cached data! iOS was caching those results, which is terrible because the result changes all the time.

Turns out over 630 people had the same frustration, as evidenced on stackoverflow:

Now I'm back to excited!  I think I introduced a small bug yesterday with the "Show Found / Hide Found" monsters, and I still have some JavaScript confirm() boxes to restyle, so I need to make a few more fixes.

In the meantime, Kathleen spent a couple hours MonsterCaching yesterday and has blown by Reed on the leader board.  She now has 33!

No comments:

Post a Comment