title: Glide: How to stop glide from loading images from cache instead load from server each time
body: <p>I tried everything possible but couldn't try to figure out how to update images to glide whenever my json is updated</p>
  
  <p>MY android app initally loads images from json using glide for firsttime after that it only load images from cache.It doesnot load images that are updated on server till i delete the app and reinstall it </p>
  
  <p>I tried using <strong>diskCacheStrategy(DiskCacheStrategy.NONE)</strong> and <strong>.skipMemoryCache(true)</strong> but nothing happened</p>
  
  <pre><code>Glide.with(mContext).load(image.getMedium())
                  .thumbnail(0.5f)
                  .crossFade()
                  .diskCacheStrategy(DiskCacheStrategy.NONE)
                  .skipMemoryCache(true)
                  .into(holder.thumbnail);
  </code></pre>
  
  <p>This is my code GalleryAdapter.java</p>
  
  <pre><code>import android.content.Context;
  import android.support.v7.widget.RecyclerView;
  import android.view.GestureDetector;
  import android.view.LayoutInflater;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  
  import com.bumptech.glide.Glide;
  import com.bumptech.glide.load.engine.DiskCacheStrategy;
  
  import java.util.List;
  
  import com.bumptech.glide.signature.StringSignature;
  import com.dailysolutions.sn.R;
  import com.dailysolutions.sn.model.Image;
  
  /**
   * Created by Sagunesh on 31/03/16.
   */
  
  public class GalleryAdapter extends RecyclerView.Adapter&lt;GalleryAdapter.MyViewHolder&gt; {
  
      private List&lt;Image&gt; images;
      private Context mContext;
  
      public class MyViewHolder extends RecyclerView.ViewHolder {
          public ImageView thumbnail;
  
          public MyViewHolder(View view) {
              super(view);
              thumbnail = (ImageView) view.findViewById(R.id.thumbnail);
          }
      }
  
  
      public GalleryAdapter(Context context, List&lt;Image&gt; images) {
          mContext = context;
          this.images = images;
      }
  
      @Override
      public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.gallery_thumbnail, parent, false);
  
          return new MyViewHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(MyViewHolder holder, int position) {
          Image image = images.get(position);
  
          Glide.with(mContext).load(image.getMedium())
                  .thumbnail(0.5f)
                  .crossFade()
                  .diskCacheStrategy(DiskCacheStrategy.NONE)
                  .skipMemoryCache(true)
                  .into(holder.thumbnail);
  
      }
  
      @Override
      public int getItemCount() {
          return images.size();
      }
  
      public interface ClickListener {
          void onClick(View view, int position);
  
          void onLongClick(View view, int position);
      }
  
      public static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {
  
          private GestureDetector gestureDetector;
          private GalleryAdapter.ClickListener clickListener;
  
          public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final GalleryAdapter.ClickListener clickListener) {
              this.clickListener = clickListener;
              gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
                  @Override
                  public boolean onSingleTapUp(MotionEvent e) {
                      return true;
                  }
  
                  @Override
                  public void onLongPress(MotionEvent e) {
                      View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
                      if (child != null &amp;&amp; clickListener != null) {
                          clickListener.onLongClick(child, recyclerView.getChildPosition(child));
                      }
                  }
              });
          }
  
          @Override
          public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
  
              View child = rv.findChildViewUnder(e.getX(), e.getY());
              if (child != null &amp;&amp; clickListener != null &amp;&amp; gestureDetector.onTouchEvent(e)) {
                  clickListener.onClick(child, rv.getChildPosition(child));
              }
              return false;
          }
  
          @Override
          public void onTouchEvent(RecyclerView rv, MotionEvent e) {
          }
  
          @Override
          public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
  
          }
      }
  }
  </code></pre>
  
  <p>Here is the code of MainActivity.java</p>
  
  <pre><code>import android.app.ProgressDialog;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.os.Bundle;
  import android.support.design.widget.NavigationView;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.widget.RecyclerView;
  import android.support.v7.widget.Toolbar;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.View;
  import android.view.MenuItem;
  import android.view.animation.Animation;
  import android.view.animation.AnimationUtils;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.bumptech.glide.Glide;
  import com.dailysolutions.sn.R;
  import com.dailysolutions.sn.adapter.GalleryAdapter;
  import com.google.android.gms.ads.AdListener;
  import com.google.android.gms.ads.AdView;
  
  import android.app.ProgressDialog;
  import android.content.DialogInterface;
  import android.os.Bundle;
  import android.support.design.widget.NavigationView;
  import android.support.v4.app.FragmentTransaction;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AlertDialog;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.DefaultItemAnimator;
  import android.support.v7.widget.GridLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.support.v7.widget.Toolbar;
  import android.util.Log;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.JsonArrayRequest;
  import com.google.android.gms.ads.AdRequest;
  
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.ArrayList;
  
  import com.dailysolutions.sn.app.AppController;
  import com.dailysolutions.sn.model.Image;
  import com.google.android.gms.ads.InterstitialAd;
  
  import java.util.ArrayList;
  
  public class MainActivity extends BaseActivity {
      private DrawerLayout drawerLayout;
      private Toolbar toolbar;
  
  
  
      private String TAG = MainActivity.class.getSimpleName();
      private static final String endpoint = "https://www.freesabkuch.com/api_mehndi/glide.json";
      private ArrayList&lt;Image&gt; images;
      private ProgressDialog pDialog;
      private GalleryAdapter mAdapter;
      private RecyclerView recyclerView;
      private AdView mAdView;
      InterstitialAd interstitial;
  
      // Our created menu to use
      private Menu mymenu;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
          toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          initNavigationDrawer();
          checkConnectivity();
  
          //advertisement
          mAdView = (AdView) findViewById(R.id.adView);
          AdRequest adRequest = new AdRequest.Builder()
                  .build();
          mAdView.loadAd(adRequest);
  
          // Prepare the Interstitial Ad
          interstitial = new InterstitialAd(MainActivity.this);
  // Insert the Ad Unit ID
          interstitial.setAdUnitId(getString(R.string.admob_interstitial_id));
  
          interstitial.loadAd(adRequest);
  // Prepare an Interstitial Ad Listener
          interstitial.setAdListener(new AdListener() {
              public void onAdLoaded() {
                  // Call displayInterstitial() function
                  displayInterstitial();
              }
          });
  
          recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
  
          pDialog = new ProgressDialog(this);
          images = new ArrayList&lt;&gt;();
          mAdapter = new GalleryAdapter(getApplicationContext(), images);
  
          RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
          recyclerView.setLayoutManager(mLayoutManager);
          recyclerView.setItemAnimator(new DefaultItemAnimator());
          recyclerView.setAdapter(mAdapter);
  
          recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(), recyclerView, new GalleryAdapter.ClickListener() {
              @Override
              public void onClick(View view, int position) {
                  Bundle bundle = new Bundle();
                  bundle.putSerializable("images", images);
                  bundle.putInt("position", position);
  
                  FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                  SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
                  newFragment.setArguments(bundle);
                  newFragment.show(ft, "slideshow");
              }
  
              @Override
              public void onLongClick(View view, int position) {
  
              }
          }));
  
          fetchImages();
  
  
  
  
      }
  
      public void displayInterstitial() {
  // If Ads are loaded, show Interstitial else show nothing.
          if (interstitial.isLoaded()) {
              interstitial.show();
          }
      }
      @Override
      public void onResume() {
          // Start or resume the game.
          super.onResume();
          displayInterstitial();
      }
      @Override
      public void onStart() {
          super.onStart();
          displayInterstitial();
      }
      private void fetchImages() {
  
          pDialog.setMessage("Downloading....");
          pDialog.show();
  
          JsonArrayRequest req = new JsonArrayRequest(endpoint,
                  new Response.Listener&lt;JSONArray&gt;() {
                      @Override
                      public void onResponse(JSONArray response) {
                          Log.d(TAG, response.toString());
                          pDialog.hide();
  
                          images.clear();
                          for (int i = 0; i &lt; response.length(); i++) {
                              try {
                                  JSONObject object = response.getJSONObject(i);
                                  Image image = new Image();
                                  image.setName(object.getString("name"));
  
                                  JSONObject url = object.getJSONObject("url");
                                  image.setSmall(url.getString("small"));
                                  image.setMedium(url.getString("medium"));
                                  image.setLarge(url.getString("large"));
                                  image.setTimestamp(object.getString("timestamp"));
  
                                  images.add(image);
  
                              } catch (JSONException e) {
                                  Log.e(TAG, "Json parsing error: " + e.getMessage());
                              }
                          }
  
                          mAdapter.notifyDataSetChanged();
                      }
                  }, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  Log.e(TAG, "Error: " + error.getMessage());
                  pDialog.hide();
              }
          });
  
          // Adding request to request queue
          AppController.getInstance().addToRequestQueue(req);
      }
  
  
  
      @Override
      public void onBackPressed() {
          exit();
      }
  
  
      public void initNavigationDrawer() {
  
          NavigationView navigationView = (NavigationView)findViewById(R.id.navigation_view);
          navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
              @Override
              public boolean onNavigationItemSelected(MenuItem menuItem) {
  
                  int id = menuItem.getItemId();
  
                  switch (id){
                      case R.id.home:
                          Toast.makeText(getApplicationContext(),"Home",Toast.LENGTH_SHORT).show();
                          drawerLayout.closeDrawers();
                          break;
                      case R.id.share:
                          Toast.makeText(getApplicationContext(),"Share",Toast.LENGTH_SHORT).show();
                          drawerLayout.closeDrawers();
                          try {
                              Intent i = new Intent(Intent.ACTION_SEND);
                              i.setType("text/plain");
                              i.putExtra(Intent.EXTRA_SUBJECT, "My application name");
                              String sAux = "\nLet me recommend you this application\n\n";
                              sAux = sAux + "https://play.google.com/store/apps/details?id=Orion.Soft \n\n";
                              i.putExtra(Intent.EXTRA_TEXT, sAux);
                              startActivity(Intent.createChooser(i, "choose one"));
                          } catch(Exception e) {
                              //e.toString();
                          }
                      case R.id.trash:
                          Toast.makeText(getApplicationContext(),"Drawer Closed",Toast.LENGTH_SHORT).show();
                          drawerLayout.closeDrawers();
                          break;
                      case R.id.logout:
                         exit();
  
                  }
                  return true;
              }
          });
          View header = navigationView.getHeaderView(0);
          TextView tv_email = (TextView)header.findViewById(R.id.tv_email);
          tv_email.setText("Daily Solutions");
          drawerLayout = (DrawerLayout)findViewById(R.id.drawer);
  
          ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.drawer_open,R.string.drawer_close){
  
              @Override
              public void onDrawerClosed(View v){
                  super.onDrawerClosed(v);
              }
  
              @Override
              public void onDrawerOpened(View v) {
                  super.onDrawerOpened(v);
              }
          };
          drawerLayout.addDrawerListener(actionBarDrawerToggle);
          actionBarDrawerToggle.syncState();
      }
      private void checkConnectivity(){
          if(ConnectionHelper.isConnectedOrConnecting(getApplicationContext())) {
              hideErrorsBar(true);
  
          }else {
              //hideErrorsBar(false);
              Intent Intent = new Intent(MainActivity.this,NoInternet.class);
              startActivity(Intent);
              finish();
          }
      }
  
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Add our menu
          getMenuInflater().inflate(R.menu.menu_main, menu);
  
          // We should save our menu so we can use it to reset our updater.
          mymenu = menu;
  
          //
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch(item.getItemId()) {
              case R.id.action_refresh:
                  // Do animation start
                  LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  ImageView iv = (ImageView)inflater.inflate(R.layout.iv_refresh, null);
                  Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotate_refresh);
                  rotation.setRepeatCount(Animation.INFINITE);
                  iv.startAnimation(rotation);
                  item.setActionView(iv);
                  new UpdateTask(this).execute();
                  return true;
          }
          return super.onOptionsItemSelected(item);
      }
  
  
      public void resetUpdating()
      {
          // Get our refresh item from the menu
          MenuItem m = mymenu.findItem(R.id.action_refresh);
          if(m.getActionView()!=null)
          {
              // Remove the animation.
              m.getActionView().clearAnimation();
              m.setActionView(null);
          }
      }
  
  
  
  }
  </code></pre>