[removed] how to force Image() not to use the browser cache?

前端 未结 4 1588
执念已碎
执念已碎 2020-12-16 18:52

If I load the nextimg URL manually in the browser, it gives a new picture every time I reload. But this bit of code shows the same image every iteration of draw()

4条回答
  •  孤城傲影
    2020-12-16 19:32

    There are actually two caches you need to bypass here: One is the regular HTTP cache, that you can avoid by using the correct HTTP headers on the image. But you've also got to stop the browser from re-using an in-memory copy of the image; if it decides it can do that it will never even get to the point of querying its cache, so HTTP headers won't help.

    To prevent this, you can use either a changing querystring or a changing fragment identifier.

    See my post here for more details.

提交回复
热议问题