How to clear browser cache when re-uploading image with same filename, in php?

后端 未结 8 1544
灰色年华
灰色年华 2021-02-18 19:05

I have a listing of items, that also contains an image thumbnail. Sometimes I need to change the thumbnail image, but keep the filename the same. Is there a way to force the bro

8条回答
  •  南旧
    南旧 (楼主)
    2021-02-18 19:48

    Cached images are also invalidated on manual page refresh (pressing F5 in browser). This can be simulated with Javascript method location.reload() being fired on body load. To avoid perpetual reloading, this may take place only once. When the user uploads a new avatar, the ReloadPending request is set persistently in his/her session and it is reset when it's been answered.

    "; 
    } else echo "";
    ?>
    

    Reloading the whole page after avatar upload will cause the page flicker but this happens only once, which, I believe, is acceptable.

提交回复
热议问题