【问题标题】:Auto purge, cloudflare and php?自动清除、cloudflare 和 php?
【发布时间】:2018-10-15 20:32:40
【问题描述】:

我的网站有一个设置页面,用户可以在其中更改她的图像配置文件,问题是。我在 cloudflare 上有 dns,所以如果用户更改了我需要在 cloudflare 上清除才能看到更改的图像,我可以在 php 上添加代码以进行自动清除?

【问题讨论】:

  • Cloudflare 是否是标准缓存问题,请更改文件的最后修改时间,或更改其 url。你也可以使用cloudflares api,但如果它缓存在浏览器中,它仍然需要一个 Shft-F5。

标签: php image caching cloudflare


【解决方案1】:

每次用户更改图像时,如何在图像 URL 旁边的数据库中保存时间戳或任何类型的标识?

然后您将显示它类似于以下内容:

<img src="https://www.yourwebsite.com/images/<?= $image->id ?>?timestamp=<?= $image->updated_at ?>">

CloudFlare 应该在更新后将此视为不同的文件。如果没有,您可以set up a page rule that matches your image url and customize the caching。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-28
    • 2018-04-07
    • 2015-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多