search

Home  >  Q&A  >  body text

android - Glide加载网络图片,显示之前的URL图片,换了URL图片还是没变

Glide加载网络图片,显示之前的URL图片,换了URL图片还是没变

ringa_leeringa_lee2772 days ago668

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 17:32:40

    I have also encountered this problem, because when Glide loads an image, it will cache the image locally. If the URL does not change, it will directly read the cache and not load it over the network.
    There are two solutions:
    1. Clear the cache every time you load. This is a very rubbish solution, which is equivalent to abandoning the very important function of caching.
    2. The image address uses this: url+? random number. When the picture is changed, just change the random number in the background, so that you will reload the network picture locally. This is the fundamental solution, and the backend should be designed like this

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 17:32:40

    Recommend an open source framework for loading images from the network, Universal Image Loader, which is very convenient to use

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:32:40

    1. You need to cooperate with the server. When the request is returned, there must be expires in the header to indicate whether the resource has expired.
    2. If the resource expires, clear the image cache and reload

    reply
    0
  • Cancelreply