473,326 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Download and cache page without displaying it?

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
May 27 '06 #1
18 2169
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/
May 27 '06 #2
"Randy Webb" <Hi************@aol.com> 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

May 27 '06 #3
"Mark" <no****@thanksanyway.org> wrote:
"Randy Webb" <Hi************@aol.com> 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.
May 27 '06 #4
Mark said the following on 5/27/2006 3:01 PM:
"Randy Webb" <Hi************@aol.com> 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/
May 28 '06 #5
"Randy Webb" <Hi************@aol.com> 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

May 29 '06 #6
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-...
May 29 '06 #7
Mark said the following on 5/29/2006 2:00 AM:
"Randy Webb" <Hi************@aol.com> 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/
May 29 '06 #8
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/
May 29 '06 #9
"Randy Webb" <Hi************@aol.com> 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
May 29 '06 #10
Mark said the following on 5/29/2006 12:18 PM:
"Randy Webb" <Hi************@aol.com> 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.


Don't use independent pages then. Just preload the next image in the
thumbnails and then change the image on the current page. The image
itself is already preloaded, so it would just be a matter of changing it:

document.images['imageName'].src = newImage

And then preload the next image.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 29 '06 #11
"Randy Webb" <Hi************@aol.com> wrote:

Don't use independent pages then. Just preload the next image in the
thumbnails and then change the image on the current page. The image itself
is already preloaded, so it would just be a matter of changing it:

document.images['imageName'].src = newImage

And then preload the next image.


Sorry, I should have been more specific. The thumbnail appears with various
text describing it (artwork title, price, availability, and so on.) So I do
need to change the page.
May 29 '06 #12
Mark said the following on 5/29/2006 3:34 PM:
"Randy Webb" <Hi************@aol.com> wrote:
Don't use independent pages then. Just preload the next image in the
thumbnails and then change the image on the current page. The image itself
is already preloaded, so it would just be a matter of changing it:

document.images['imageName'].src = newImage

And then preload the next image.


Sorry, I should have been more specific. The thumbnail appears with various
text describing it (artwork title, price, availability, and so on.) So I do
need to change the page.


You can change the text on the page as well as the image.

<URL: http://jibbering.com/faq/#FAQ4_15>

IF you are preloading the image, you could get the text from the server
as well and change the innerHTML of a div tag accordingly.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 29 '06 #13
"Randy Webb" <Hi************@aol.com> wrote:

You can change the text on the page as well as the image.

<URL: http://jibbering.com/faq/#FAQ4_15>

IF you are preloading the image, you could get the text from the server as
well and change the innerHTML of a div tag accordingly.


Hmm. . .I would still need to query the server to obtain the text to be
displayed with the next image in the scroll order. How would I do that
without loading a new HTML page? XMLHttpRequest, perhaps?
May 29 '06 #14
Mark said the following on 5/29/2006 7:16 PM:
"Randy Webb" <Hi************@aol.com> wrote:
You can change the text on the page as well as the image.

<URL: http://jibbering.com/faq/#FAQ4_15>

IF you are preloading the image, you could get the text from the server as
well and change the innerHTML of a div tag accordingly.


Hmm. . .I would still need to query the server to obtain the text to be
displayed with the next image in the scroll order. How would I do that
without loading a new HTML page? XMLHttpRequest, perhaps?


Perhaps XMLHTTPRequest but if it were me, I would just dynamically load
a .js file that only needed to have two or three variables defined and a
simple function call:

var nextImage = "nextImagePath";
var nextImageText = "Text for next Image";
var anotherImage = true/false;
someFunctionInThePageToUpdateIt();

Where anotherImage would be a boolean that the server could write out to
let you know if there is indeed another image coming next or if you have
reached the end of the line in which case the nextImageText could be:

"You have reached the end of the Internet, there are no more images to
see". (Seen that commercial?)

Search the archives for "Dynamically load JS Files" along with my name.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 30 '06 #15
"Randy Webb" <Hi************@aol.com> wrote:

Search the archives for "Dynamically load JS Files" along with my name.


I can't find it. Can you post the URI?
May 30 '06 #16
Mark said the following on 5/30/2006 4:53 PM:
"Randy Webb" <Hi************@aol.com> wrote:
Search the archives for "Dynamically load JS Files" along with my name.


I can't find it. Can you post the URI?


function loadJSFile(fileURL){
var loadScript = document.createElement('script');
loadScript.type = "text/javascript";
loadScript.src = fileURL;
document.getElementsByTagName('head')[0].appendChild(loadScript);
}

and then call it like this:

loadJSFile('URL to .js File');

How much further you take that function depends on how far backwards
compatible you want to go. It needs some feature detection for
createElement, getElementsByTagName and appendChild.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 30 '06 #17
"Randy Webb" <Hi************@aol.com> wrote:

function loadJSFile(fileURL){
var loadScript = document.createElement('script');
loadScript.type = "text/javascript";
loadScript.src = fileURL;
document.getElementsByTagName('head')[0].appendChild(loadScript);
}

and then call it like this:

loadJSFile('URL to .js File');


Ok, but would this not require that I have a collection of javascript files
defined on the server, one for each set of data that I plan to display to
the client? If so, then I could still create the JS files programmatically
on the server, but I would need to give them user-specific naming (including
the user's IP and the system time in the JS filename for example.) I would
also need a server-side cleanup routine to periodically dispose of orphaned
JS files.

If this is the case, then XMLHttpRequest() might be a better approach, no?

May 31 '06 #18
Mark said the following on 5/31/2006 11:30 AM:
"Randy Webb" <Hi************@aol.com> wrote:
function loadJSFile(fileURL){
var loadScript = document.createElement('script');
loadScript.type = "text/javascript";
loadScript.src = fileURL;
document.getElementsByTagName('head')[0].appendChild(loadScript);
}

and then call it like this:

loadJSFile('URL to .js File');

Ok, but would this not require that I have a collection of javascript files
defined on the server, one for each set of data that I plan to display to
the client?


Yes. But as I understand it, you have a collection of html files now
that have that data and image and other HTML data in alreay.
If so, then I could still create the JS files programmatically on the server,
but I would need to give them user-specific naming (including the user's IP
and the system time in the JS filename for example.)
No, you just need a static .js file for each image is all. Or, you could
just have a DB with the data, and then a single server side script file
that dynamically created the return data to the browser.
I would also need a server-side cleanup routine to periodically dispose of orphaned
JS files.
No different than having to clean up orphaned HTML files now.
If this is the case, then XMLHttpRequest() might be a better approach, no?


No.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 31 '06 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Don Peters | last post by:
I'm relatively new to ASP.NET. I'm running it under Win XP Pro, using Visual Studio 2002.NET (haven't migrated to VS2003 yet). The ASP.NET application I'm having a problem with was initially set...
6
by: chon | last post by:
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This...
3
by: Ron Lessnick | last post by:
I have to continuously download the same web page on our IIS server. It is important to always download a fresh page from the server including not only the .asp page itself but all the .gif and...
4
by: dave | last post by:
hi I'm building a page that displays all phone in phoneview.asp...however from admin section we can add new phone image tht stores path in database. I wanna use cache object in phoneview.asp..becoz...
4
by: C16 | last post by:
Hi All I have a simple download script for files on my website and I use the code below to download the files: $fp = fopen($filename, "rb"); if ( $fp ) { $filesize = $file;
2
by: Don Peters | last post by:
I'm relatively new to ASP.NET. I'm running it under Win XP Pro, using Visual Studio 2002.NET (haven't migrated to VS2003 yet). The ASP.NET application I'm having a problem with was initially set...
5
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. ...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.