By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,640 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,640 IT Pros & Developers. It's quick & easy.

Ajax caching on pages...

P: n/a
Mel
I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.

Is there a way to prevent this from happenning ?

Mar 19 '07 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Mel said the following on 3/19/2007 11:45 AM:
I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.

Is there a way to prevent this from happenning ?
Yes, use a unique URL by adding a timestamp to the URL.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 19 '07 #2

P: n/a
Randy Webb <Hi************@aol.comwrote in
news:hf********************@giganews.com:
Mel said the following on 3/19/2007 11:45 AM:
>I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.

Is there a way to prevent this from happenning ?

Yes, use a unique URL by adding a timestamp to the URL.
if you can get to the headers, you can help it too... here is a snippet of
code from my PHP generating pages:

//IE actually caches ajax pages. Just another reason to hate that browser.
header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache")
Mar 19 '07 #3

P: n/a
Good Man said the following on 3/19/2007 5:03 PM:
Randy Webb <Hi************@aol.comwrote in
news:hf********************@giganews.com:
>Mel said the following on 3/19/2007 11:45 AM:
>>I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.

Is there a way to prevent this from happenning ?
Yes, use a unique URL by adding a timestamp to the URL.

if you can get to the headers, you can help it too... here is a snippet of
code from my PHP generating pages:

//IE actually caches ajax pages. Just another reason to hate that browser.
Hate a browser because it doesn't act the way you want it to instead of
learning how to code it. Intuitive.
header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache")
There is still no guarantee even setting the headers. Adding a timestamp
to the URL is proven to be reliable.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 19 '07 #4

P: n/a
On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:
Good Man said the following on 3/19/2007 5:03 PM:
>Randy Webb <Hi************@aol.comwrote in
news:hf********************@giganews.com:
>>Mel said the following on 3/19/2007 11:45 AM:
I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.

Is there a way to prevent this from happenning ?
Yes, use a unique URL by adding a timestamp to the URL.

if you can get to the headers, you can help it too... here is a snippet
of code from my PHP generating pages:

//IE actually caches ajax pages. Just another reason to hate that
browser.

Hate a browser because it doesn't act the way you want it to instead of
learning how to code it. Intuitive.
It's pretty easy to hate a browser that continually shifts its
"standards", I've seen many websites that render fine in IE6 that don't
render properly in IE7.

The function of a browser is write once display anywhere... so this is
clearly a failure on MS's part not in the programmers.
Mar 19 '07 #5

P: n/a
Ivan Marsh said the following on 3/19/2007 6:11 PM:
On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:
>Good Man said the following on 3/19/2007 5:03 PM:
>>Randy Webb <Hi************@aol.comwrote in
news:hf********************@giganews.com:

Mel said the following on 3/19/2007 11:45 AM:
I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.
>
Is there a way to prevent this from happenning ?
Yes, use a unique URL by adding a timestamp to the URL.
if you can get to the headers, you can help it too... here is a snippet
of code from my PHP generating pages:

//IE actually caches ajax pages. Just another reason to hate that
browser.
Hate a browser because it doesn't act the way you want it to instead of
learning how to code it. Intuitive.

It's pretty easy to hate a browser that continually shifts its
"standards", I've seen many websites that render fine in IE6 that don't
render properly in IE7.
I guess you have never tried dynamically creating a table in IE/FF then?
IE gets it right, FF gets it dead wrong. The list is endless both ways.
The function of a browser is write once display anywhere...
No, the function of a browser is to display the resource given to it.
so this is clearly a failure on MS's part not in the programmers.
The same can also be said about FF, Mozilla, Opera, Safari and any other
browser you want to name. Doesn't mean you hate the browser, it means
you learn how to deal with it.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 19 '07 #6

P: n/a
On Mon, 19 Mar 2007 18:24:17 -0400, Randy Webb wrote:
Ivan Marsh said the following on 3/19/2007 6:11 PM:
>On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:
>>Good Man said the following on 3/19/2007 5:03 PM:
Randy Webb <Hi************@aol.comwrote in
news:hf********************@giganews.com:

Mel said the following on 3/19/2007 11:45 AM:
>I have a page with a <DIVthat gets updated every 10 seconds. The
>problem is that unless the browser is configured to get new pages at
>all times, it displays the page from cache.
>>
>Is there a way to prevent this from happenning ?
Yes, use a unique URL by adding a timestamp to the URL.
if you can get to the headers, you can help it too... here is a snippet
of code from my PHP generating pages:

//IE actually caches ajax pages. Just another reason to hate that
browser.
Hate a browser because it doesn't act the way you want it to instead of
learning how to code it. Intuitive.

It's pretty easy to hate a browser that continually shifts its
"standards", I've seen many websites that render fine in IE6 that don't
render properly in IE7.

I guess you have never tried dynamically creating a table in IE/FF then?
IE gets it right, FF gets it dead wrong. The list is endless both ways.
>The function of a browser is write once display anywhere...

No, the function of a browser is to display the resource given to it.
>so this is clearly a failure on MS's part not in the programmers.

The same can also be said about FF, Mozilla, Opera, Safari and any other
browser you want to name. Doesn't mean you hate the browser, it means
you learn how to deal with it.
So you think it's perfectly okay for three versions of the same browser
from the same company to display the same information three different ways?

You're very forgiving.
Mar 19 '07 #7

P: n/a
Ivan Marsh said the following on 3/19/2007 6:26 PM:
On Mon, 19 Mar 2007 18:24:17 -0400, Randy Webb wrote:
>Ivan Marsh said the following on 3/19/2007 6:11 PM:
>>On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:

Good Man said the following on 3/19/2007 5:03 PM:
Randy Webb <Hi************@aol.comwrote in
news:hf********************@giganews.com:
>
>Mel said the following on 3/19/2007 11:45 AM:
>>I have a page with a <DIVthat gets updated every 10 seconds. The
>>problem is that unless the browser is configured to get new pages at
>>all times, it displays the page from cache.
>>>
>>Is there a way to prevent this from happenning ?
>Yes, use a unique URL by adding a timestamp to the URL.
if you can get to the headers, you can help it too... here is a snippet
of code from my PHP generating pages:
>
//IE actually caches ajax pages. Just another reason to hate that
browser.
Hate a browser because it doesn't act the way you want it to instead of
learning how to code it. Intuitive.
It's pretty easy to hate a browser that continually shifts its
"standards", I've seen many websites that render fine in IE6 that don't
render properly in IE7.
I guess you have never tried dynamically creating a table in IE/FF then?
IE gets it right, FF gets it dead wrong. The list is endless both ways.
>>The function of a browser is write once display anywhere...
No, the function of a browser is to display the resource given to it.
>>so this is clearly a failure on MS's part not in the programmers.
The same can also be said about FF, Mozilla, Opera, Safari and any other
browser you want to name. Doesn't mean you hate the browser, it means
you learn how to deal with it.

So you think it's perfectly okay for three versions of the same browser
from the same company to display the same information three different ways?
Just curious, but did you ask the same thing when NS7 came out with
regards to three different versions displaying the same information
three different ways? Or, is it just MS that makes it "different"?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 19 '07 #8

P: n/a
On Mon, 19 Mar 2007 19:05:22 -0400, Randy Webb wrote:
Ivan Marsh said the following on 3/19/2007 6:26 PM:
>On Mon, 19 Mar 2007 18:24:17 -0400, Randy Webb wrote:
>>Ivan Marsh said the following on 3/19/2007 6:11 PM:
On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:

Good Man said the following on 3/19/2007 5:03 PM:
>Randy Webb <Hi************@aol.comwrote in
>news:hf********************@giganews.com:
>>
>>Mel said the following on 3/19/2007 11:45 AM:
>>>I have a page with a <DIVthat gets updated every 10 seconds.
>>>The problem is that unless the browser is configured to get new
>>>pages at all times, it displays the page from cache.
>>>>
>>>Is there a way to prevent this from happenning ?
>>Yes, use a unique URL by adding a timestamp to the URL.
>if you can get to the headers, you can help it too... here is a
>snippet of code from my PHP generating pages:
>>
>//IE actually caches ajax pages. Just another reason to hate that
>browser.
Hate a browser because it doesn't act the way you want it to instead
of learning how to code it. Intuitive.
It's pretty easy to hate a browser that continually shifts its
"standards", I've seen many websites that render fine in IE6 that
don't render properly in IE7.
I guess you have never tried dynamically creating a table in IE/FF
then? IE gets it right, FF gets it dead wrong. The list is endless
both ways.

The function of a browser is write once display anywhere...
No, the function of a browser is to display the resource given to it.

so this is clearly a failure on MS's part not in the programmers.
The same can also be said about FF, Mozilla, Opera, Safari and any
other browser you want to name. Doesn't mean you hate the browser, it
means you learn how to deal with it.

So you think it's perfectly okay for three versions of the same browser
from the same company to display the same information three different
ways?

Just curious, but did you ask the same thing when NS7 came out with
regards to three different versions displaying the same information
three different ways? Or, is it just MS that makes it "different"?
I do remember one occasion where minor changes in the way Netscape
rendered caused issue with some web sites... in Netscape 6.0
Mar 20 '07 #9

P: n/a
Ivan Marsh said the following on 3/20/2007 10:45 AM:
On Mon, 19 Mar 2007 19:05:22 -0400, Randy Webb wrote:
>Ivan Marsh said the following on 3/19/2007 6:26 PM:
>>On Mon, 19 Mar 2007 18:24:17 -0400, Randy Webb wrote:

Ivan Marsh said the following on 3/19/2007 6:11 PM:
On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:
>
<snip>
>>>>so this is clearly a failure on MS's part not in the programmers.
The same can also be said about FF, Mozilla, Opera, Safari and any
other browser you want to name. Doesn't mean you hate the browser, it
means you learn how to deal with it.
So you think it's perfectly okay for three versions of the same browser
from the same company to display the same information three different
ways?
Just curious, but did you ask the same thing when NS7 came out with
regards to three different versions displaying the same information
three different ways? Or, is it just MS that makes it "different"?

I do remember one occasion where minor changes in the way Netscape
rendered caused issue with some web sites... in Netscape 6.0
Did you "Hate Netscape" or write it off as a cost of progress?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 20 '07 #10

P: n/a
On Tue, 20 Mar 2007 12:18:48 -0400, Randy Webb wrote:
Ivan Marsh said the following on 3/20/2007 10:45 AM:
>On Mon, 19 Mar 2007 19:05:22 -0400, Randy Webb wrote:
>>Ivan Marsh said the following on 3/19/2007 6:26 PM:
On Mon, 19 Mar 2007 18:24:17 -0400, Randy Webb wrote:

Ivan Marsh said the following on 3/19/2007 6:11 PM:
>On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:
>>
>>
<snip>
>>>>>so this is clearly a failure on MS's part not in the programmers.
The same can also be said about FF, Mozilla, Opera, Safari and any
other browser you want to name. Doesn't mean you hate the browser,
it means you learn how to deal with it.
So you think it's perfectly okay for three versions of the same
browser from the same company to display the same information three
different ways?
Just curious, but did you ask the same thing when NS7 came out with
regards to three different versions displaying the same information
three different ways? Or, is it just MS that makes it "different"?

I do remember one occasion where minor changes in the way Netscape
rendered caused issue with some web sites... in Netscape 6.0

Did you "Hate Netscape" or write it off as a cost of progress?
I can forgive a single incident, maybe even two... but I did stop using
Netscape shortly after that.

It's a bit surprising to find there's someone in the world defending
incompetence, lack of adherence to standards and chaos in general. You
must be a truly interesting person.
Mar 20 '07 #11

P: n/a
Ivan Marsh said the following on 3/20/2007 2:35 PM:
On Tue, 20 Mar 2007 12:18:48 -0400, Randy Webb wrote:
>Ivan Marsh said the following on 3/20/2007 10:45 AM:
>>On Mon, 19 Mar 2007 19:05:22 -0400, Randy Webb wrote:

Ivan Marsh said the following on 3/19/2007 6:26 PM:
On Mon, 19 Mar 2007 18:24:17 -0400, Randy Webb wrote:
>
>Ivan Marsh said the following on 3/19/2007 6:11 PM:
>>On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:
>>>
>>>
<snip>
>>>>>>so this is clearly a failure on MS's part not in the programmers.
>The same can also be said about FF, Mozilla, Opera, Safari and any
>other browser you want to name. Doesn't mean you hate the browser,
>it means you learn how to deal with it.
So you think it's perfectly okay for three versions of the same
browser from the same company to display the same information three
different ways?
Just curious, but did you ask the same thing when NS7 came out with
regards to three different versions displaying the same information
three different ways? Or, is it just MS that makes it "different"?
I do remember one occasion where minor changes in the way Netscape
rendered caused issue with some web sites... in Netscape 6.0
Did you "Hate Netscape" or write it off as a cost of progress?

I can forgive a single incident, maybe even two... but I did stop using
Netscape shortly after that.
Then I would guess that you don't use IE?
It's a bit surprising to find there's someone in the world defending
incompetence, lack of adherence to standards and chaos in general.
I wasn't defending MS, I was questioning the reasoning behind "I hate
IE" as it seems that MS is just the target of it. Nothing more, nothing
less. If the accusations go across the board then it is fine. But when
people say "I hate IE" simply to seem "cool" (think M$ as well) it
seems, well, odd.
You must be a truly interesting person.
The people around me say that I am a one of a kind and most of them say
prayers to be thankful for it :)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 20 '07 #12

P: n/a
On Tue, 20 Mar 2007 19:49:35 -0400, Randy Webb wrote:
Ivan Marsh said the following on 3/20/2007 2:35 PM:
>On Tue, 20 Mar 2007 12:18:48 -0400, Randy Webb wrote:
>>Ivan Marsh said the following on 3/20/2007 10:45 AM:
On Mon, 19 Mar 2007 19:05:22 -0400, Randy Webb wrote:

Ivan Marsh said the following on 3/19/2007 6:26 PM:
>On Mon, 19 Mar 2007 18:24:17 -0400, Randy Webb wrote:
>>
>>Ivan Marsh said the following on 3/19/2007 6:11 PM:
>>>On Mon, 19 Mar 2007 17:54:30 -0400, Randy Webb wrote:
>>>>
>>>>
<snip>

>>>so this is clearly a failure on MS's part not in the programmers.
>>The same can also be said about FF, Mozilla, Opera, Safari and any
>>other browser you want to name. Doesn't mean you hate the browser,
>>it means you learn how to deal with it.
>So you think it's perfectly okay for three versions of the same
>browser from the same company to display the same information three
>different ways?
Just curious, but did you ask the same thing when NS7 came out with
regards to three different versions displaying the same information
three different ways? Or, is it just MS that makes it "different"?
I do remember one occasion where minor changes in the way Netscape
rendered caused issue with some web sites... in Netscape 6.0
Did you "Hate Netscape" or write it off as a cost of progress?

I can forgive a single incident, maybe even two... but I did stop using
Netscape shortly after that.

Then I would guess that you don't use IE?
>It's a bit surprising to find there's someone in the world defending
incompetence, lack of adherence to standards and chaos in general.

I wasn't defending MS, I was questioning the reasoning behind "I hate
IE" as it seems that MS is just the target of it. Nothing more, nothing
less. If the accusations go across the board then it is fine. But when
people say "I hate IE" simply to seem "cool" (think M$ as well) it
seems, well, odd.
There's an alleged group of people in the world that believe it makes them
seem cool to say "I hate IE"?

I can't decide which is more ridiculous... that being true or anyone
caring.

Mar 21 '07 #13

This discussion thread is closed

Replies have been disabled for this discussion.