简体   繁体   English

缓存动态GD映像

[英]Caching Dynamic GD Image

How would I cache a image that may change every few minutes so it is only generated, lets say, once a hour? 我将如何缓存每隔几分钟便会更改一次的图像,使其仅每小时生成一次(例如)?

I was told something like this? 有人告诉我这样的事吗?

                header('Content-type: image/png');
                header("Cache-Control: private, max-age=10800, pre-check=10800");
                header("Pragma: private");
                header("Expires: " . date(DATE_RFC822,strtotime(" 1 hour")));

But it does update with every change, which I'm not sure if that mean it's not caching or changes overwrite the cache? 但是它确实会随着每次更改而更新,我不确定这是否意味着它没有缓存或更改会覆盖缓存?

I tried looking through some other topics but they didn't address my specific issue, or linked to dead pages. 我尝试浏览其他一些主题,但是它们没有解决我的特定问题,也没有链接到无效页面。

I highly recommend SLIR (Smart Lencioni Image Resizer). 我强烈推荐SLIR(Smart Lencioni Image Resizer)。 It's found here: 在这里找到:

https://github.com/lencioni/SLIR https://github.com/lencioni/SLIR

Among other wonderful abilities (on the fly/dynamic resizing, auto-crop, etc.), it caches all rendered images for the length of time you provide in its config file. 除了其他出色的功能(动态/动态调整大小,自动裁剪等)之外,它还会在您在其配置文件中提供的时间范围内缓存所有渲染的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM