How to keep image caches longer in chromium --help

331 views
Skip to first unread message

曾benny

unread,
Feb 21, 2019, 1:18:49 AM2/21/19
to Chromium-discuss

When Chromium load a page with hundreds of tags which are created by JS, hundred of images are cached. But if Chromium loaded another page,all the cached images would be released. Everytime Chromium come back to the page from other pages, it always take a bit long to download the image resource.

Is there any way to keeps the image cached longer?Someone can help?

Jon Perryman

unread,
Feb 22, 2019, 9:44:28 PM2/22/19
to benn...@126.com, Chromium-discuss
I'm guessing that you are saying that chrome does use cached images when coming back to a  web page using javascript to insert those images. You don't mention how you know cache is not being referenced. The correct method is to use the network tab in developer tools. Specifically, you should look at the size field for each of the images. "from memory cache", "from disk cache" and 184 bytes (or something much smaller than the image) identify the cache is being used. Otherwise download size should be around the size of the image. You can for a download by holding shift and clicking on refresh. 

I tested the simple HTML below and it used the cache. I suggest you test a few images instead of hundreds. If caching doesn't work, then try your page on another computer. Maybe you have a bad setting. If caching works for a few images but not hundreds, then I suspect your cache size is too small. If so, then it's probably loosing an mage every time it reads a new one. Remember that when you access other web pages, they too will be cached. As it reads new data to be cached, chrome will need to free cache when the cache is too small.

<html><body><div id='images'></div></body>
<script>
images = "";
function show_image(src) {
    images += "<img src='"+src+"'/>";
}
 document.getElementById("images").innerHTML = images;
</script>
</html>

Regards, Jon.

On Wed, Feb 20, 2019 at 10:18 PM 曾benny <benn...@126.com> wrote:

When Chromium load a page with hundreds of tags which are created by JS, hundred of images are cached. But if Chromium loaded another page,all the cached images would be released. Everytime Chromium come back to the page from other pages, it always take a bit long to download the image resource.

Is there any way to keeps the image cached longer?Someone can help?

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
    http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.

benny

unread,
Feb 25, 2019, 10:01:02 PM2/25/19
to Chromium-discuss
Dear Jon,

Thanks for your information.

I tested your simple HTML. I could see images "from memory cache" in dev tool tab. But the web page I met gets all images by downloading everytime.

I have tracked the flows in Chromium.ThreadState::performIdleGC() will finally lead to the release of the image caches(memory cache). It seems that if Chromium perform GC, image caches will be released. I have done an experiment.I changed the threshold of Chromium GC. I could see images got from memory caches. But there is a problem, when switched between two pages two or three times, Chromium will finally perform GC and image caches released.

I check the behavior on Opera, It can be switched tens of times without getting images by downloading.

Do you have any idea how to keep the image caches work longer?Just like Opera.


Best Regards,Benny.

Jon Perryman

unread,
Feb 26, 2019, 2:30:15 PM2/26/19
to Chromium-discuss
Hi Benny,

Find out why you don't get any "from disk cache". After images are evicted from memory cache, you should have at least a few "from disk cache" (your test scenario - not your huge app). Maybe you have a corrupted disk cache. 

Regards, Jon. 

benny

unread,
Feb 28, 2019, 8:22:22 PM2/28/19
to Chromium-discuss
Hi Jon,
Thank you very much!

I check the disk cache settings. Only 20KB space allowed for disk cache!We all taked it as 20MB because we used the wrong unit. I change it to 20MB. It works good now.

Best regards.
Benny.
Reply all
Reply to author
Forward
0 new messages