[Webkit-unassigned] [Bug 32423] Incorrect cache behavior with dynamic scripts after page-refresh

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Dec 14 17:01:24 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=32423





--- Comment #2 from Kyle Simpson <getify at gmail.com>  2009-12-14 17:01:24 PST ---
@Alexey -- I appreciate you taking a look. I'm sorry that it is confusing, but
it should be obvious with the amount of time I took to explain and the several
test cases that this is far more than an "amusing" observation of quirks. The
behavior I've identified represents a real problem that I'm very interested in
doing whatever it takes to help address.

The bug I describe has been independently confirmed by a number of other
developers, and as I mentioned, was also confirmed (and even an attempt at an
explanation) by the Chromium developers over on the other bug thread.

I would be *more* than happy/willing to discuss this bug to any level of detail
necessary to help explain it fully and help find the cause and solution. I can
do so via messages here in this thread, IM, twitter, separate email, even
phone. Please just let me know what channel will best help explain and clear up
confusion over the bug and test cases.

---------------

I didn't default to cluttering up this thread with a detailed explanation of
exactly WHY i would be doing something so "crazy" as trying to load the same
script URL multiple times in the same page (moreover, loading it with different
mime-types each time), but it is in fact a big problem I've run into and I
currently have no workarounds or solutions other than hoping Webkit will
address the bug.

The behavior/bug was discovered when developing and testing my project LABjs
(http://labjs.com) which is a dynamic script loader (for improving page load
performance) developed in cooperation with Steve Souders. LABjs uses a variety
of different "tricks" (depending on browser) to be able to "load" scripts in
parallel, but prevent their automatic execution, so that they can be executed
later in specific order.

Specifically, one of these tricks, a key critical piece of functionality in
LABjs, is to load a script URL with a fake mime-type like "script/preload",
which will cause the browser to fetch the script (into the cache) but will NOT
execute it. Then later, when LABjs determines it's time to execute the script,
it adds another script dom element with the EXACT same URL, but with a proper
mime-type "text/javascript". This should pull the script nearly immediately
from cache (from the first attempt) and of course execute it basically right
away.

---------------

The test cases I presented don't use LABjs (although the LABjs test suite will
also show the same symptoms), they just represent the simple parts of the logic
necessary to demonstrate the bug, extracted and presented (hopefully more
clearly) to help demonstrate that it's not a code logic error but a behavior of
the browser.

The "test-1" test case behaves PROPERLY on first page load, but starts
misbehaving after a page refresh (of various kinds). The same is true of LABjs.
Because the exact same code logic behaves differently between first pageview
and refreshed pageview, it should show the behavior lies within the browser
internals.

So what happens is that on *first pageview*, a particular script URL is only
loaded ONCE from server, even though two adds/attempts are made. This is
because the script is correctly cached after the first request, as desired, and
thus the second attempt later in that page's lifetime pulls from cache rather
than from the server.

However, when you then refresh that page, you see clearly that the same two
attempts to load a script URL result in TWO full loads from server, because the
script isn't properly cached with the first request like it is on
first-pageview.

The other tests show slight variations which, for whatever reason, cause the
bug to NOT appear. My hope with presenting these other negative test cases
would be that the by seeing what is NOT buggy along with what IS buggy, it
would help identify exactly where/why the bug is.

---------------

To recap, the very real "problem" this bug presents is costly unnecessary extra
loads of scripts into a page (upon a page refresh), which not only creates more
server/network traffic load, but also can significantly slow down the page view
performance itself in the browser. 

Clearly, the point of LABjs being to improve page load performance, it's a very
bad thing that this bug actually causes LABjs to make page performance much
worse (only for Webkit browser) than if it hadn't even been used at all! So,
I'm very interested in helping get this addressed.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list