file_exists() is too slow in PHP. Can anyone suggest a faster alternative?

后端 未结 19 1465
迷失自我
迷失自我 2021-02-05 01:18

When displaying images on our website, we check if the file exists with a call to file_exists(). We fall back to a dummy image if the file was missing.

Howe

19条回答
  •  眼角桃花
    2021-02-05 01:52

    Create a hashing routine for sharding the files into multiple sub-directories.

    filename.jpg -> 012345 -> /01/23/45.jpg

    Also, you could use mod_rewrite to return your placeholder image for requests to your image directory that 404.

提交回复
热议问题