mozilla / webmaker-core

React-based core for Webmaker shared across all platforms
https://foundation.mozilla.org/en/artifacts/webmaker/
Mozilla Public License 2.0
65 stars 39 forks source link

Discover doesn't update, can't refresh #1010

Closed xmatthewx closed 8 years ago

xmatthewx commented 8 years ago

Pull-to-refresh no longer works in the Discover view.

The most recently featured projects do not appear in Discover (even after 2 weeks). Cache doesn't seem to expire. This second issue might not be new ... might have been hidden by the ability to use pull-to-refresh.

cc @ryanwse @alanmoo @gvn

ryanwarsaw commented 8 years ago

Dupe of #931

It broke with the crosswalk update, I'll see what I can do about fixing it.

xmatthewx commented 8 years ago

Pull-to-refresh itself isn't essential. When a user returns to the view, we need to check the server to make sure the cache is recent enough.

ryanwarsaw commented 8 years ago

@xmatthewx Oh, okay. I'll take a look at that, seems pretty straight forward though.

alanmoo commented 8 years ago

After looking through the code with @xmatthewx, I feel like it's pretty likely there's been a caching issue from the start, and that we simply didn't notice it because pull-to-refresh was there. It seems what we really need is a timeout on the cache. https://github.com/mozilla/webmaker-core/blob/develop/src/lib/api.js#L47-L88 may be the culprit, as it seems that if a cache exists, it will always be used. If we can add a way to check the date of the stored cache and throw it out if it's older than X hours (or doesn't have a time stamp at all), that should take care of the issue.

xmatthewx commented 8 years ago

Thanks for the notes @alanmoo. I discussed this with @ryanwse. Here's the basic plan:

We'll make sure we're storing a timestamp with the cache, and check that on view load. For now, a simple expiration after one hour will be good enough.

Feature updates are done manually and not frequently. We just need to unlock permanent cache and prevent constant unnecessary updates. In a future release, if needed, we can actually fetch a small update to test the cache against.

ryanwarsaw commented 8 years ago

I looked at this in-depth today, the app appears to be showing 19 project entries in the discovery page, and I also get 19 entries when I query the /discover route of the staging API. This would suggest that there is either an issue with how moderators are attempting to feature projects, or how the API is handling those requests.

I'd also like to note that in further testing, I can confirm there is no issue in regards to how caching works in Webmaker for Android, as it uses the LruCache caching system, a cache designed to organize information within it in order of how often its accessed, in order to improve speed & efficiency. This caching system is memory based, and is thrown away when the app is closed (along with the data).

xmatthewx commented 8 years ago

I just featured 2 more projects on the staging DB. You should now see 21. Let's schedule a time to talk over video to see if we can reproduce the error. My beta app on device still doesn't display the most recently featured projects.

xmatthewx commented 8 years ago

Problem appears to be with cache on the server. API doesn't return all the projects marked as featured in the DB. No obvious pattern with the missing projects. Most likely they were just featured later than the others.

xmatthewx commented 8 years ago

Closing. This is not a bug. More of a planning flaw. (Sigh) See #1016