douren0558 2010-07-20 09:21
浏览 61
已采纳

浏览器请求图像

I've been doing some experimenting with php and html, and I'd like to know if it's possible for the browser to send a separate request for multiple images that have the same file name. For example, if I had

<img src="showimg.php?id=1234"> 

written out 3 different times, is it possible for the browser to send the request 3 different times, thus getting a different image each time? It seems so far that the browser recognizes that the file name is the same and then just serves up the image from the cache. I came to this conclusion by using a session variable that increments every time showimg.php is accessed. If the id is different then the counter gets incremented 3 times. But if all three id's are the same then the counter only gets incremented once no matter how many times I request the image. Since I am no authority on browsers, I was hoping someone could provide a concrete answer.

EDIT: My question is: How can I force the browser to load a different image using the same id. I know it can be done with unique ids. I'm just wondering if this is possible.

Thank you to those who have responded so far, though.

  • 写回答

2条回答 默认 最新

  • dsg24156 2010-07-20 09:31
    关注

    I think the only choice you have is to append some random string to the image to make the "file name" unique. Otherwise the browser will (rightly) assume that files with the same URL are the same image. From a REST point of view, they should be.

    <img src="showimg.php?id=1234&rand=<?php echo uniqid(); ?>"> 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大