From: Thomas 'PointedEars' Lahn on
SleeplessAndy wrote:

> We have a site with some .js files that due to size/wan speed we want
> to stay cached. Why could they be sticking around for about 10
> different document loads, accessing the file, browsing away to other
> pages, then back to similar docs using the file again, thenn suddenly
> it gets deleted. The IE cache is set for testing to 5mb, and the file
> sticks around, even though the cache continually goes up to this limit
> and above, and other files are replaced. Then suddenly, a page load
> will cause the large .js file to be removed, even though the expiry is
> 30 days in the future.
>
> I don't understand. Any help gratefully received!

The problem might have to do with the way you load the ".js files". Not
understanding how HTTP caching works has led many people to believe that
using a variant query-part when referring to resources would be a proper
solution, e.g.:

document.write('<script type="text/javascript" src="foo.js?'
+ (+new Date()) + '"><\/script>');

Of course, this means that a HTTP client regards every such resource a
single entity, which fills HTTP caches much faster than if the recommended
method, cache control¹, would have been used (for example, it would take
only 10 reloads of a cached HTML document including 5 script resources of
100 kB size each until a cache of 5 MB size was full²). As a result, other,
especially larger resources need to be removed from the cache earlier if the
policy is that the cache size should not exceed a certain limit.

However, I recommend to set the IE cache size to something between 20 and
100 "MB". (42 works for me, of course ;-))

That said, in my experience IE's caching mechanism, at least in IE 6.0 and
7.0, appeared to be borken in several places.

It is difficult to see why you would post this problem to a newsgroup
dealing with Internet Information Server/Services, and another one dealing
with ECMAScript-based script programming, instead of to one dealing
specifically with Microsoft Internet Explorer.

You should also be aware that Microsoft has announced that beginning in June
2010, they would begin closing their newsgroups, so it might not be the best
idea to use the microsoft.* hierarchy anymore.³

<http://www.catb.org/~esr/faqs/smart-questions.html>


F'up2 cljs

PointedEars
___________
¹ <http://www.mnot.net/cache_docs/>
² For simplicity, I am using SI units here (I do not know what IE uses):
1 MB = 1000 kB = 1'000'000 bytes (but 1 MiB = 1024 KiB = 1'048'576 bytes)
³ <http://www.microsoft.com/communities/newsgroups/default.mspx>
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee