Is there a way to force browsers to refresh/download images?

后端 未结 14 2182
囚心锁ツ
囚心锁ツ 2020-11-29 01:21

I have a problem where users are reporting that their images aren\'t being uploaded and the old ones are still there. On closer inspection the new images are there, they jus

相关标签:
14条回答
  • 2020-11-29 02:08

    Go Random. Just use some random number and append it with image filename.

    <img src="image.jpg?<?=rand(1,1000000)?>">
    
    0 讨论(0)
  • 2020-11-29 02:10

    My favourite PHP solution:

    <img src="<?php echo "image.jpg" . "?v=" . filemtime("image.jpg"); ?>" />
    

    every change of file "create" a new version of the file

    0 讨论(0)
提交回复
热议问题