How to implement web cache: internal fragmentation VS external fragmentation

Posted by Summer_More_More_Tea on Stack Overflow See other posts from Stack Overflow or by Summer_More_More_Tea
Published on 2010-04-15T14:50:32Z Indexed on 2010/04/15 14:53 UTC
Read the original article Hit count: 274

Filed under:

Hi there:

I come up with this question when play with Firefox web cache: in which approach does the browser cache a response in limited disk space(take my configuration as an example, 50MB is the upper bound)?

I think two ways can be employed. One is cache the total response object one by one, but this is inefficient and will introduce external fragmentation, thus the total cache space may not be fully used. The second is take the total space(50MB) as a consecutive file, splitting it into fixed-length slots; incoming response objects will also be treated blocks of data with the same length as the slots. We can fill slots until the whole file is run out of, then some displacement algorithm can be used to swap out the old cached objects. The latter approach will of course bing in internal fragmentation, but in my opinion is easier to implement and maintain than the first strategy.

But when I enter Firefox's Cache directory, I find it (maybe) use a different method: a lot of varied-length files reside in that directory and all those files are filled with undisplayable characters. I don't but really want to know what mechanism that a commercial browser, e.g. Firefoix, employed to implement web cache.

Regards.

© Stack Overflow or respective owner

Related posts about web-applications