how to clear or replace a cached image

后端 未结 20 1645
囚心锁ツ
囚心锁ツ 2020-11-29 02:04

I know there are many ways to prevent image caching (such as via META tags), as well as a few nice tricks to ensure that the current version of an image is shown with every

20条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 02:27

    Here is a solution using the PHP function filemtime():

     
     >
    

    Use the file modified time as a parameter will cause it to read from a cached version until the file has changed. This approach is better than using e.g. a random number as caching will still work if the file has not changed.

提交回复
热议问题