一个缓存问题的解决方法

更新的图片没有显示出来,还是显示旧图片。

在chrome中开发者工具中禁用cache也不起作用。Status Code是正常值200

用firefox的web开发者工具查看调用情况,发现Status code是304.

The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource. This happens when the request method is safe, like a GET or a HEAD request, or when the request is conditional and uses a If-None-Match or a If-Modified-Since header.

The equivalent 200 OK response would have included the headers Cache-Control, Content-Location, Date, ETag, Expires, and Vary.

解决方法:由于网站使用了cloudflare的cdn,登陆cloudflare后,在相应的Caching/Purge Cache中,点击custom purge,在弹出的对话框中输入图片的地址,点击purge按钮。问题解决!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.