search

Home  >  Q&A  >  body text

android 微信是如何实现即时更新好友头像的

微信好友的头像肯定是做缓存的,那么好友头像修改后,用户这边是如何实现立即就能看到修改后的头像的呢?

迷茫迷茫2771 days ago1675

reply all(5)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 18:00:48

    If you want to achieve real-time updates: you need to use push. After A modifies his avatar, he notifies the server, and the server then sends a push notification to A's friends to update A's avatar.

    reply
    0
  • 迷茫

    迷茫2017-04-17 18:00:48

    The first thing to pull must be the avatar URL. The local cache is based on the URL. Every time the local cache pulls the avatar URL and then loads it through the loading module, it will judge whether the currently cached image is consistent with this URL. Otherwise, it will be inconsistent. Download through the new url.

    reply
    0
  • PHPz

    PHPz2017-04-17 18:00:48

    Save a field in the database: the last avatar modification time.

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 18:00:48

    Let’s speculate, the process in brackets is a wild guess:
    User A uploads a new avatar → the server processes the new avatar → stores the new avatar URL in a field in the user table, recording the change time (→ synchronizes the avatar to CDN → updates The avatar URL field of the user table records the change time) → the server sends a push to the online client → the client updates the avatar.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 18:00:48

    Take a guess, you can set a identification field, the default is 0, set it to 1 when the user updates the avatar, and push this identification at the same time when pushing messages or regular synchronization.
    While processing messages or regularly synchronizing contact information, the mobile phone determines this identifier. If the identifier is 1, it means that the friend has uploaded a new avatar. At this time, a GET request is made to pull the new avatar and cache it locally, and at the same time, the server-side identifier is updated. 0, to prevent repeated requests for avatars during the next synchronization.
    (PS: Just some personal thoughts.)

    reply
    0
  • Cancelreply