防止缓存gd图像 [英] prevent caching of gd image

查看:70
本文介绍了防止缓存gd图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想阻止gd生成的图像被缓存。


它被调用到index.php文件中,如下所示:


< image src =

" http://www.daveches.co.uk/importimage/importimage.php?x = $ randomNumber"

alt ="战斗区域 USEMAP = QUOT;#battlegrid" border =" 0">


(importimage4real.php包含加载和修改的gd功能

图片)。


上面代码中的随机数查询字符串试图欺骗浏览器认为图像与其中的图像不同。

其缓存。但它仍然显示其图像的缓存版本。


我已尝试过每次停止缓存标题我可以在

index.php和importimage.php中想到,设置过期到过去的时间,其余都是

。仍然,刷新浏览器:你获得缓存,而不是

最新的图像(在ie6和Firefox中相同)。几分钟之后

到期后你会获得最新版本的刷新,但这不是

对我的申请有用。


托管公司服务器上的某些设置是否可能会覆盖我可以进行的任何更改?


dave Cheseldine

解决方案

randomNumber"

alt =" battle area" USEMAP = QUOT;#battlegrid" border =" 0">


(importimage4real.php包含加载和修改的gd功能

图片)。


上面代码中的随机数查询字符串试图欺骗浏览器认为图像与其中的图像不同。

其缓存。但它仍然显示其图像的缓存版本。


我已尝试过每次停止缓存标题我可以在

index.php和importimage.php中想到,设置过期到过去的时间,其余都是

。仍然,刷新浏览器:你获得缓存,而不是

最新的图像(在ie6和Firefox中相同)。几分钟之后

到期后你会获得最新版本的刷新,但这不是

对我的申请有用。


托管公司服务器上的某些设置是否可能会覆盖我可以进行的任何更改?


dave Cheseldine


它可能不仅仅是PHP缓存..你检查IE和firefox

浏览器设置了吗?在IE中:工具>互联网选项>设置检查是否

设置显示缓存是如何完成的...这可能会有所帮助。


在导入时尝试此操作图片脚本。


// ****大量标题以确保图像不被缓存。

//过去的日期

header(" Expires:Mon,26 Jul 1997 05:00:00 GMT");

//始终修改

header(" Last-修改:。gmdate(" D,d MYH:i:s)。GMT);

// HTTP / 1.1

标题(" ; Cache-Control:no-store,no-cache,must-revalidate");

header(" Cache-Control:post-check = 0,pre-check = 0",false) ;

// HTTP / 1.0

header(" Pragma:no-cache");

// ****结束糟糕的标题。


这不是我自己的工作,我不记得我从哪里得到它但是它

为我工作一个类似的应用程序。


问候,


AD7six


Hi
I want to stop a gd generated image from being cached.

It is called into index.php file as follows:

<image src =
"http://www.daveches.co.uk/importimage/importimage.php?x=$randomNumber"
alt = "battle area" usemap="#battlegrid" border="0">

(importimage4real.php contains the gd functionality that load and modify
the image).

The random number querystring in the code above is an attempt to trick
the browser into thinking the image is different from what it has in
its cache. But still it displays its cached version of the image.

I have tried every "stop caching" header I can think of in both
index.php and importimage.php, set expires to a time in the past and all
the rest. Still, refresh the browser: you get the cached, not the
latest, image (same in ie6 and Firefox). After a few minutes something
expires and you do get the latest version by Refreshing, but this is no
good for my application.

Is it possible that some settings on my hosting company''s server are
overwriting any changes I can make?

dave Cheseldine

解决方案

randomNumber"
alt = "battle area" usemap="#battlegrid" border="0">

(importimage4real.php contains the gd functionality that load and modify
the image).

The random number querystring in the code above is an attempt to trick
the browser into thinking the image is different from what it has in
its cache. But still it displays its cached version of the image.

I have tried every "stop caching" header I can think of in both
index.php and importimage.php, set expires to a time in the past and all
the rest. Still, refresh the browser: you get the cached, not the
latest, image (same in ie6 and Firefox). After a few minutes something
expires and you do get the latest version by Refreshing, but this is no
good for my application.

Is it possible that some settings on my hosting company''s server are
overwriting any changes I can make?

dave Cheseldine


It might not be just the PHP caching.. Did u check the IE and firefox
browser setting? in IE: Tools > Internet Options > Settings check if
the setting shows you how the caching is done.. this might help.


Try this in your import image script.

//**** Lots of headers to ensure the image is not cached.
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
//**** End of crappy headers.

It''s not my own work, and I don''t remember where I got it from but it
worked for me for a similar application.

Regards,

AD7six


这篇关于防止缓存gd图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆