Status: Unconfirmed
Owner: ----
Labels: Type-Bug Pri-2 OS-All Area-Misc

New issue 23162 by getify: Cache ignored on page-refresh for some dynamic  
scripts with cache-headers
http://code.google.com/p/chromium/issues/detail?id=23162

Chrome Version       : 3.0.195.21 (Official Build 26042)
URLs (if applicable) :
Other browsers tested: IE6-8, Safari 4 (win)
   Add OK or FAIL after other browsers where you have tested this issue:
      Safari 4: OK
   Firefox 3.x: n/a
          IE 7: OK
          IE 8: OK

What steps will reproduce the problem?
1. Dynamically add a few script-elements to the DOM (via
document.createElement), whose URL is a dynamic script (.php for instance)
with url ? paramaters. Generate random-number url parameters for the
scripts so that on each page load, a new set of scripts is guaranteed.
2. Make sure in the server script to output valid cache headers with far-
future-expires.
3. Attempt to re-add later *to the same page* one or more of the scripts
that should have been cached by #1 above.
4. Watch server logs, notice that all scripts were reloaded from cache
(nearly immediately) without hits to the server. Good!
5. Now, hit F5 or click the refresh button, refreshing the page (and thus
generating a fresh set of script urls to download for that new page
instance).
6. Then, re-add those same script urls to the page a second time (same as
#3), and watch server logs.
7. Close the page/browser, and reopen to the page, again obviously
regenerating a fresh set of urls to download for the page instance.
8. Then, again, re-add the same script urls to the page a second time (as
with #3 and #6), and watch server logs.


What is the expected result?
In #6 and #8, I expect all scripts to be reloaded from cache in the same
page instance, when added to the page the second time, just like in #4.

What happens instead?
In #8 (after a clean opening of the page) they are, but in #6 (after a
F5/refrehs), one or more of the scripts are *not* reloaded from cache when
added the second time, but are instead reloaded from server as if missing
from cache. This same behavior persists on the page through mulitple
refrehes. But, once the page is closed and reopened, the happy behavior of
using the cache for reloads in the same page instance comes back. It only
starts being flaky after a F5/refresh.

Please provide any additional information below. Attach a screenshot if
possible.

This may sound like strange interaction to be doing on a page. Let me give
some context of a use-case example where this might be necessary.

Say you have a page that needs to download several JSON data packets,
and/or maybe certain script logic. You generate a dynamic URL for that
page-instance for each script. There are user interactions like button
clicks which will initiate reloads of such scripts. But, you decide you
really want a page-session (that is, a single load of the page) to never
request those scripts more than once, and to the use the cache on
subsequent user interactions as they click buttons. But, once they refresh
the page, you want them to get a fresh set of scripts.

How I actually discovered the problem: I am using a set of script logic
that adds the script elements to the page with a type of "text/html",
which causes the browser to download the script to cache, but *not*
execute it. Then, later in the page, I add a script element with the same
url, but with type "text/javascript", and it should pull it immediately
from cache. This is basically a "precaching" type of technique, but
controlling execution time.

This precaching technique works, and uses the cache the second time later
in the page instance, in all other browsers (IE6-8 and Safari 4), and it
works in Chrome, except in the case noted above. It's not applicable to
FF/Opera, as those browsers don't allow you to "precache" with
the "text/html" technique (so I use other methods instead in those
browsers).

Also, this behavior is ONLY seen when the URL's of the the ".php" dynamic
type (even though there are valid cache headers sent). If the same tests
are performed with actual .js files, everything works fine, even after
refreshes.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/group/chromium-bugs
-~----------~----~----~----~------~----~------~--~---

Reply via email to