疯狂缓存!! [英] crazy cache !!

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

问题描述

我有一个页面,我可以上传和删除图像。


我有这样的问题我正在努力解决。我的图片编号为xxxx-1.jpg,

xxxx-2.jpg,xxxx-3.jpg(其中xxxx是文章编号)。


现在,当使用删除第二张图片时,我更新数据库为

,将xxxx-3.jpg重命名为xxxx-2.jpg,并且我在
$上重命名该文件b $ b服务器。


问题:如果我转到文章页面,则会显示OLD xxxx-2.jpg。我已经刷了CTRL来刷新以获得正确的图像。此外,如果我再次回到

再次管理这些图片,那么第三个被定义删除,并且

xxxx-2.jpg显示旧的,而不是xxxx- 3.jpg重命名。


如何避免服务器存储这样的想法?我不想要缓存

这样的图片。


Bob

I''ve a page where I can upload and delete images.

I''ve such problem I''m trying to solve. My images are numbered xxxx-1.jpg,
xxxx-2.jpg, xxxx-3.jpg (where xxxx is the article number).

Now, when the used deletes the 2nd pictures, then I update the database for
having the xxxx-3.jpg renamed in xxxx-2.jpg and also I rename the file on
the server.

Problem: if I go to the article page, then the OLD xxxx-2.jpg is shown. I''ve
to refresh with CTRL pushed to get the correct image. Also if I come back to
manage those pictures again, then the third is definetively removed, and the
xxxx-2.jpg shown the old one, not the xxxx-3.jpg renamed.

How to avoid the server to store such think ? I don''t want the cache for
such pictures.

Bob

推荐答案

在文章< 43 ********************** @ news.sunrise.ch> ;,

" Bob贝德福德" <是****** @ notforspammershotmail.com>写道:
In article <43**********************@news.sunrise.ch>,
"Bob Bedford" <be******@notforspammershotmail.com> wrote:
我有一个页面,我可以上传和删除图像。

我有这样的问题,我正在努力解决。我的图像编号为xxxx-1.jpg,
xxxx-2.jpg,xxxx-3.jpg(其中xxxx是文章编号)。

现在,当使用时删除第2个图片,然后我更新数据库,以便在xxxx-2.jpg中重命名xxxx-3.jpg,并在服务器上重命名该文件。

问题:如果我转到文章页面,则会显示OLD xxxx-2.jpg。我已经刷新了CTRL以获得正确的图像。此外,如果我再次回到
管理这些图片,那么第三个被定义删除,并且
xxxx-2.jpg显示旧的,而不是xxxx-3.jpg重命名。

如何避免服务器存储这样的想法?我不想要缓存这样的图片。
I''ve a page where I can upload and delete images.

I''ve such problem I''m trying to solve. My images are numbered xxxx-1.jpg,
xxxx-2.jpg, xxxx-3.jpg (where xxxx is the article number).

Now, when the used deletes the 2nd pictures, then I update the database for
having the xxxx-3.jpg renamed in xxxx-2.jpg and also I rename the file on
the server.

Problem: if I go to the article page, then the OLD xxxx-2.jpg is shown. I''ve
to refresh with CTRL pushed to get the correct image. Also if I come back to
manage those pictures again, then the third is definetively removed, and the
xxxx-2.jpg shown the old one, not the xxxx-3.jpg renamed.

How to avoid the server to store such think ? I don''t want the cache for
such pictures.




它是浏览器中的缓存,而不是服务器。

-

Sandman [.net]



It''s the cache in the browser, not the server.
--
Sandman[.net]


您的浏览器正在执行缓存,而不是服务器。在< img>上添加一个随机的

字符串到''src''标签。即< img

src =" /myfile-1.jpg?random =<?= rand(1000,9999)?>" />

your browser is doing the "caching", not the server. add a random
string to the ''src'' on the <img> tag. ie <img
src="/myfile-1.jpg?random=<?= rand(1000,9999) ?>" />


你可以做很多事情,有些比其他人更好

在某些浏览器/情况下。为了好运,我把它们全部放进去了。


header(" Expires:Mon,26 Jul 1997 05:00:00 GMT"); //过去的日期

标题(Last-Modified:。gmdate(" D,d M Y H:i:s")。GMT); //

总是被修改

header(" Cache-Control:no-store,no-cache,must-revalidate"); //

HTTP / 1.1

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

header(" Pragma:no-cache"); // HTTP / 1.0

Ian

There are a number of things you can do, some work better than others
in certain browsers/circumstances. I put them all in, just for luck...

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //
always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); //
HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
Ian


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

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