0

I've developed an app that creates groups for meeting events and works this way:

  1. In a listview (that belongs to Fragment A managed by Activity A) the app shows all the groups. This listview is populated by an AsyncTask that makes an HTTP GET Request (using Apache HTTPClient) to an Restful WS.
  2. In this Activity (Activity A) the user can go to another Activity (Activity B) in order to create a new group. To create a new group the app use another AsyncTask that makes an HTTP PUT Request to the same WS.
  3. After the group's creation, the user is redirected back to the Activity A in order to see the available groups where the new group should be included.

The problem is i'm getting the same list that was presented in the item 1 from above. This list only refresh after i click the refresh button a couple of times as if it had some sort of cache.

Solutions that i've tried to avoid cache, unsuccessfully:

  1. Using Transactions (source) to make the inserts faster (i'm doing about 10/20 inserts for group) in the Database (i'm using InnoDB engine).
  2. Using SQL_NO_CACHE (source) to prevent MySQL from place the result in the cache (i'm using this to get the groups list - Activity A).
  3. Adding to the HTTP GET Request the following header "Cache-Control: no-cache" (source 1, source 2) (i'm using this to get the groups list - Activity A).
  4. Clearing the app cache (source) whenever the user leaves the Activity A so that when he returns from the Activity B gets the list of groups already with the new group included.

Only works if i try to get the groups list inside Activity B, when the user creates a new group. In this case the WS returns an updated list with the new group included. After that if I return to the Activity A the outdated list is shown again.

How can i prevent use cache in the Activity A?

Thanks

Community
  • 1
  • 1
gfam
  • 1
  • 1

1 Answers1

0

Try to add parameter using the current time in millisecond

something like this :

String myurl="http://example.com/myserv.php?getit=labla&currenttime="+System.currentTimeMillis();
Developer So far
  • 353
  • 1
  • 11