A simple HTML code:
<img src="http://someaddr/image.php">
image.php is a script that returns a random Redirect to a static image with all necessary no-cache headers:
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
Location: http://someaddr/random_image_12345.jpg
The problem: when navigating back and forward to this HTML page, Chrome (latest win/mac) does not revalidate address http://someaddr/image.php
.
I have tried using redirects 302 and also 303 (which in RFC has stronger requirement that it should NEVER been cached by browser). This works like a charm in IE, FireFox, Opera. They always refresh http://someaddr/image.php
. But Chrome doesn't.
I have even used Developer Tools in Chrome, and it seems that in Network Log it even don't shows any attempt (cached or not) of fetching http://someaddr/image.php
. Network Log shows only one connection already to http://someaddr/random_image_12345.jpg
(cached). Why this is so broken...
I know the naive/simple solution of putting query string in image source:
<img src="http://someaddr/image.php?refresh={any random number or timestamp}">
But I don't like/can't use hacks like that. Are there ANY other options?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…