Chrome image caching (without reloading the page)

时间:2018-12-19 11:37:16

标签: google-chrome cache-control etag

I have an angular application which loads html documents from a backend server these documents also include images.

On these files i have an eTag header and cache-control: no-cache. When i do an ajax request i see that the HTML documents get checked using the eTag but the images are not checked they are just retrieved from the cache.

When i request the images again after a while (+- 5 minutes) then chrome does check the images with the server by eTag.

I tried changing to cache-control: no-store and this appears to be working for the images now they are retrieved from the server on every request. But when no-store is used then the browser wont use the eTag and always downloads the files (as it should).

I know that i could add a time variable to the url (image.png?12345) and that works aswell, but again then the eTag is not used and the images are downloaded every request.

Am i doing something wrong or is chrome adding some extra caching logic for images?

1 个答案:

答案 0 :(得分:0)

尝试修改网址,使其看起来像(image.png?eTag = your_tag)。这样一来,一旦eTag更改,图像就会重新加载。