Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Download and cache page without displaying it?

Reply
Thread Tools

Download and cache page without displaying it?

 
 
Mark
Guest
Posts: n/a
 
      05-27-2006
Hello.

I am looking for a way to download and cache a web page that the user has
not yet requested, and write the web page to the browser cache without
displaying it. My intention is to improve display performance when the user
eventually requests the cached document.

Is there a way to do this in Javascript?

Thanks
-Mark


 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      05-27-2006
Mark said the following on 5/27/2006 2:32 PM:
> Hello.
>
> I am looking for a way to download and cache a web page that the user has
> not yet requested, and write the web page to the browser cache without
> displaying it.


And how can you ensure that the user is going to request it?

Load it in a hidden IFrame, it will get cached and then if it is
requested then it will half way do what you want it to do.

> My intention is to improve display performance when the user
> eventually requests the cached document.


You are looking in the wrong direction.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
 
 
 
Mark
Guest
Posts: n/a
 
      05-27-2006
"Randy Webb" <(E-Mail Removed)> wrote:
>
> And how can you ensure that the user is going to request it?


I can't be sure. But it is likely. The context is one in which the user is
invited to scroll through a series of images which are displayed
one-at-a-time (a server-side Perl CGI script retrieves the image information
from a database and generates the web page.)

I have improved performance quite a bit by preloading the image that will be
displayed on the next page in the sequence. I'm just wondering whether I can
take that a step further and preload the entire page.

>
> Load it in a hidden IFrame, it will get cached and then if it is requested
> then it will half way do what you want it to do.


Thanks, I'll give that a look.

>
> You are looking in the wrong direction.


I am always happy to have someone point me in the right direction. You are
welcome to blindfold me, spin me around a few times, and place a keyboard in
my hand. . .

-Mark



 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      05-27-2006
"Mark" <(E-Mail Removed)> wrote:
> "Randy Webb" <(E-Mail Removed)> wrote:
>>
>> Load it in a hidden IFrame, it will get cached and then if it is
>> requested then it will half way do what you want it to do.

>
> Thanks, I'll give that a look.
>


Hmm. . .recursion. Luckily there are only a few dozen images in the
database.


 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      05-28-2006
Mark said the following on 5/27/2006 3:01 PM:
> "Randy Webb" <(E-Mail Removed)> wrote:
>> And how can you ensure that the user is going to request it?

>
> I can't be sure. But it is likely. The context is one in which the user is
> invited to scroll through a series of images which are displayed
> one-at-a-time (a server-side Perl CGI script retrieves the image information
> from a database and generates the web page.)


Is it a thumbnail scenario where the user browses through the thumbnails
on a single page or does every image have it's own thumbnail on it's own
page?

> I have improved performance quite a bit by preloading the image that will be
> displayed on the next page in the sequence. I'm just wondering whether I can
> take that a step further and preload the entire page.


Sure. That is the basis for AOL/Netscapes "Top Speed Technology" where
it attempts to preload potential pages the user might load while the
user isn't loading anything and thus it can be considered "download down
time".

>> Load it in a hidden IFrame, it will get cached and then if it is requested
>> then it will half way do what you want it to do.

>
> Thanks, I'll give that a look.
>
>> You are looking in the wrong direction.

>
> I am always happy to have someone point me in the right direction. You are
> welcome to blindfold me, spin me around a few times, and place a keyboard in
> my hand. . .


If the load time of a plain HTML document is large enough that you are
attempting to speed up that load time, you may want to look at trimming
down the page/HTML itself - if possible. But, trying to blanket preload
any potential page that a user may go to is going to be a challenge on
any page that has more than 2 or 3 links in it.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      05-29-2006
"Randy Webb" <(E-Mail Removed)> wrote:
>
> Is it a thumbnail scenario where the user browses through the thumbnails
> on a single page or does every image have it's own thumbnail on it's own
> page?


One thumbnail per page. There are arrows to scroll forwards and backwards.


> But, trying to blanket preload any potential page that a user may go to is
> going to be a challenge on any page that has more than 2 or 3 links in it.


Nope, I just want to preload the page that the user will be loading if he
presses the forward scroll button.

I tried it with an Iframe, and it did work. But of course the contents of
the Iframe are interpreted and its scripts executed, which causes the next
page in the scroll sequence to be downloaded. . .and then the next. . .and
then the next. . .

Ideally what I would like to do is create a new document object outside of
any context where its contents would be interpreted. Just download it, and
stick it in the browser cache. But my investigation so far has uncovered no
apparent way to do this. I must use an Iframe, or create a document object
in a new window context. In either case the downloaded page will be
interpreted and its scripts executed, leading to recursion.

-Mark



 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-29-2006
Mark wrote:

> I am looking for a way to download and cache a web page that the user has
> not yet requested, and write the web page to the browser cache without
> displaying it. My intention is to improve display performance when the
> user eventually requests the cached document.
>
> Is there a way to do this in Javascript?


There is no way at all. Because with regard to display performance, such
attempts at preloading at first _decrease_ that performance in favor of
the /generally/ less likely event that exactly the preloaded content is
accessed later.

Believe it or not, users /like/ incremental display. The obvious reason
is that they can see, and possibly use, the top of the content /before/
the bottom is loaded.

Don't get me wrong: This is not to say preloading is a Bad Thing. It
is certainly useful (iff it works, you have no control over the cache
features) if a dynamic effect needs to work regardless of known timing
issues. But such /excessive/ preloading as you want it, is nonsense.


PointedEars
--
Indiana Jones: The Name of God. Jehovah.
Professor Henry Jones: But in the Latin alphabet,
"Jehovah" begins with an "I".
Indiana Jones: J-...
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      05-29-2006
Mark said the following on 5/29/2006 2:00 AM:
> "Randy Webb" <(E-Mail Removed)> wrote:
>> Is it a thumbnail scenario where the user browses through the thumbnails
>> on a single page or does every image have it's own thumbnail on it's own
>> page?

>
> One thumbnail per page. There are arrows to scroll forwards and backwards.


If the pages you are trying to preload are taking a while to load,
something is wrong in the page you are trying to preload. If you are
already loading the image, the only thing left to load is the html file
and the time to load a html file should be negligent compared to the
loading of the images.

>
>> But, trying to blanket preload any potential page that a user may go to is
>> going to be a challenge on any page that has more than 2 or 3 links in it.

>
> Nope, I just want to preload the page that the user will be loading if he
> presses the forward scroll button.
>
> I tried it with an Iframe, and it did work. But of course the contents of
> the Iframe are interpreted and its scripts executed, which causes the next
> page in the scroll sequence to be downloaded. . .and then the next. . .and
> then the next. . .


Have your IFrame check to see if it is the top document or if it is in
an IFrame. If it is not in an IFrame, load the next page. If it is in an
IFrame, you do nothing.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      05-29-2006
Thomas 'PointedEars' Lahn said the following on 5/29/2006 7:43 AM:
> Mark wrote:
>
>> I am looking for a way to download and cache a web page that the user has
>> not yet requested, and write the web page to the browser cache without
>> displaying it. My intention is to improve display performance when the
>> user eventually requests the cached document.
>>
>> Is there a way to do this in Javascript?

>
> There is no way at all.


Yes there is.

> Because with regard to display performance, such attempts at preloading
> at first _decrease_ that performance in favor of the /generally/ less
> likely event that exactly the preloaded content is accessed later.


I suppose you use that same argument to tell people not to pre-load
images? It is a flawed argument. Trying to preload the next page does
not decrease the display performance for the current page if it is
implemented correctly and uses the browsers "down time" for making HTTP
Requests to the server.

> Believe it or not, users /like/ incremental display.


That has nothing to do with the question. It wasn't about trying to
speed up the current page, it was about trying to speed up the
transition from one page to the next.

And no, users do not like to wait. Given the same exact content/pages,
if a user is confronted with two scenarios:

Scenario 1: Pages flow seemlessly, no wait.
Scenario 2: User has to wait for the next page to load.

The user will inevitably use the first page more often.

> The obvious reason is that they can see, and possibly use, the top
> of the content /before/ the bottom is loaded.


That wasn't the issue. Please read it carefully again.

> Don't get me wrong: This is not to say preloading is a Bad Thing.


Huh? Even in this one post you are contradicting yourself. You say
trying to preload decreases performance and argue against it, then you
say it isn't a bad thing. Make up your mind please.

> It is certainly useful (iff it works, you have no control over the cache
> features) if a dynamic effect needs to work regardless of known timing
> issues. But such /excessive/ preloading as you want it, is nonsense.


"excessive preloading"? WTF are you smoking? Trying to preload one image
and an HTML file is *not* "excessive preloading" by *any* stretch of the
imagination.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      05-29-2006
"Randy Webb" <(E-Mail Removed)> wrote:
>
> If the pages you are trying to preload are taking a while to load,
> something is wrong in the page you are trying to preload. If you are
> already loading the image, the only thing left to load is the html file
> and the time to load a html file should be negligent compared to the
> loading of the images.


You are correct. Preloading the image has improved performance
substantially. I am just trying to eke out that last bit of performance to
make the transition a bit "snappier." And of course the improvement would be
even more noticeable to a user on dialup.

> Have your IFrame check to see if it is the top document or if it is in an
> IFrame. If it is not in an IFrame, load the next page. If it is in an
> IFrame, you do nothing.


Ah, good idea. Thanks, I will try that.

-Mark


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
no-cache - need to reload page from server and not the cache John HTML 2 10-29-2006 05:35 PM
What's the purpose of the helper cache and is there a way to just turn off helper cache-ing? kevin Ruby 1 07-21-2006 03:42 AM
How to not cache all elements of a web page download? Ron Lessnick ASP General 2 02-04-2005 03:21 PM
Page.Cache vs HttpContext.Current.Cache DesignerX ASP .Net 5 01-20-2004 10:55 PM



Advertisments