防止缓存gd图像

编程入门 行业动态 更新时间:2024-10-10 04:25:49
本文介绍了防止缓存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 = "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图像

本文发布于:2023-11-01 11:00:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549156.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   图像   gd

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!