473,237 Members | 1,098 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,237 software developers and data experts.

Preventing Browser-caching between Frames

Hello,
my web-application uses two frames, one with a list of database
records, one with a record detail view. From the detail view there is
"mark" function that will mark the respective record in the list frame
(with a special color).
Now this mark function is meant to toggle the mark status in the list
frame, i.e. switch it on with the first click and off with the second.
Problem is, the marking works, but the second click will not have any
effect. Only when I click on another link in the list frame and _then_
click "mark" again will the marking be switched off.
I assume this is due to the browser caching the request, and when it
gets two times the same request (i.e. "list_records.php?marknode=42"),
just ignores the second one. All no-cache parameters are already set in
the headers, like:
header("Cache-Control: no-store, no-cache, must-revalidate");

(as described in the PHP manual), but this doesn't seem to work.
Or maybe the described behaviour is based on something else?
Thanks for hints!

Sep 17 '06 #1
15 2442
bvdb wrote:
Hello,
my web-application uses two frames, one with a list of database
records, one with a record detail view. From the detail view there is
"mark" function that will mark the respective record in the list frame
(with a special color).
Now this mark function is meant to toggle the mark status in the list
frame, i.e. switch it on with the first click and off with the second.
Problem is, the marking works, but the second click will not have any
effect. Only when I click on another link in the list frame and _then_
click "mark" again will the marking be switched off.
I assume this is due to the browser caching the request, and when it
gets two times the same request (i.e. "list_records.php?marknode=42"),
just ignores the second one. All no-cache parameters are already set in
the headers, like:
header("Cache-Control: no-store, no-cache, must-revalidate");

(as described in the PHP manual), but this doesn't seem to work.
Or maybe the described behaviour is based on something else?
Thanks for hints!
Hi,

[Why not post this is a Javascript newsgroup?]

Two things:
1) You didn't describe how you detect the click.
Try using the onClick-event handler in Javascript to test is your browser is
missing clicks. Just make a function that says hello.
<span onClick="alert('I am clicked');">some record</span>

2) Caching. *IF* this is a caching-issue, just append some timestamp to the
url to prevent caching.
From php:
<a href="detailedview.php?recordid=<?= $recordid ?>&t=<?= microtime() ?>">
recordlink here</a>

I just made up the recordid, I guess you managed that part already.
The addition t=543289765983475 makes sure every url is different each time.
That will prevent retrieving cached records.

Hope that helps.
If not, post some examplecode.

Regards,
Erwin

Sep 18 '06 #2
Hello,
Erwin Moller wrote:
....
[Why not post this is a Javascript newsgroup?]
Because there is no Javascript involved in my code, just HTML and PHP.
Two things:
1) You didn't describe how you detect the click.
Try using the onClick-event handler in Javascript ...
My code works fine:
If I load the list frame in a separate window and reload it the marking
gets toggled on and off each time.
2) Caching. *IF* this is a caching-issue, just append some timestamp to the
url to prevent caching.
This only works if the whole page would be regenerated - but the record
frame remains the same, so the timestamp would also stay the same which
makes it senseless.

Sep 18 '06 #3
bvdb wrote:
Hello,
Erwin Moller wrote:
...
>>[Why not post this is a Javascript newsgroup?]


Because there is no Javascript involved in my code, just HTML and PHP.

>>Two things:
1) You didn't describe how you detect the click.
Try using the onClick-event handler in Javascript ...


My code works fine:
If I load the list frame in a separate window and reload it the marking
gets toggled on and off each time.

>>2) Caching. *IF* this is a caching-issue, just append some timestamp to the
url to prevent caching.


This only works if the whole page would be regenerated - but the record
frame remains the same, so the timestamp would also stay the same which
makes it senseless.
The problem is each frame pretty much acts like a separate window from
the server's POV. That is, you can't force a frame to load from the
server end. You can update your data in one frame and send it to the
server. But only that frame will get updated - PHP can't force another
frame to get updated.

For that you'll have to use Javascript to request the second frame be
reloaded.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 18 '06 #4
Hello,
Jerry Stuckle wrote:
The problem is each frame pretty much acts like a separate window from
the server's POV. That is, you can't force a frame to load from the
server end.
Of course not. That's why I'm calling it from the record-frame with a
target='listframe' clause.
It works once and then again after I do something else in the list
frame. So my code works, the frame structure is okay, only the browser
ignores the second (same) call.
For that you'll have to use Javascript to request the second frame be
reloaded.
No, sorry, Javascript really is not a question nor a solution here.

Sep 18 '06 #5
bvdb wrote:
Hello,
Jerry Stuckle wrote:
>>The problem is each frame pretty much acts like a separate window from
the server's POV. That is, you can't force a frame to load from the
server end.


Of course not. That's why I'm calling it from the record-frame with a
target='listframe' clause.
It works once and then again after I do something else in the list
frame. So my code works, the frame structure is okay, only the browser
ignores the second (same) call.

>>For that you'll have to use Javascript to request the second frame be
reloaded.


No, sorry, Javascript really is not a question nor a solution here.
In that case I'm not sure why it would fail. But it does not look like
a PHP problem - probably something in the HTML. You might try alt.html
for more help.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 18 '06 #6
Jerry, it is not a downright "PHP problem", more a general "web server
programming problem" - but as the web server programming language of my
choice happens to be PHP, and I assume(d) many PHP programmers face
the same problem with frames, I posted the question here.
Maybe there is someone out there with a practical solution.

Sep 19 '06 #7
bvdb wrote:
Jerry, it is not a downright "PHP problem", more a general "web server
programming problem" - but as the web server programming language of my
choice happens to be PHP, and I assume(d) many PHP programmers face
the same problem with frames, I posted the question here.
Maybe there is someone out there with a practical solution.
No, it isn't. And it isn't a PHP problem at all.

Don't you think you would get a better response on a group which would
handle this type of problem - and has cross-language support? Such as
alt.html?

Just because you're using PHP doesn't necessarily make this the "best"
group. And just because you're having a particular (non-php) problem
doesn't mean others have.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 19 '06 #8
Hello,
Jerry Stuckle wrote:
bvdb wrote:
....
Maybe there is someone out there with a practical solution.

No, it isn't.
How can you know who is reading and posting in this newsgroup?
Do you have a list of people who is willing to post here?
Seems like you're a very arrogant person.
And it isn't a PHP problem at all.
It's tighly connected to PHP.
PHP offers the header() function and describes in the manual how to use
it to avoid this browser behaviour. So it fits very well into PHP
questions, better than HTML.
Just because you're using PHP doesn't necessarily make this the "best"
group.
But a very good choice. Until you stepped in.

Sep 19 '06 #9
bvdb wrote:
Hello,
Jerry Stuckle wrote:
>>bvdb wrote:

...
>>>Maybe there is someone out there with a practical solution.

No, it isn't.


How can you know who is reading and posting in this newsgroup?
Do you have a list of people who is willing to post here?
Seems like you're a very arrogant person.
No, I'm trying to direct you to the best possible resource for your
question. But you are too thick-skulled to understand it.
>
>>And it isn't a PHP problem at all.


It's tighly connected to PHP.
PHP offers the header() function and describes in the manual how to use
it to avoid this browser behaviour. So it fits very well into PHP
questions, better than HTML.
No, it's not "tightly connected to PHP". This is strictly HTML and
browser behavior. All the header() function does is send a header to
the browser. This would be exactly the same if the header were
generated in PHP, Perl, VBScript or even HTML itself. PHP has nothing
to do with it other than sending the header (just like the other
languages would have nothing to do with it).
>
>>Just because you're using PHP doesn't necessarily make this the "best"
group.


But a very good choice. Until you stepped in.
No, it was not a good choice. Look how many answers you've gotten.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 19 '06 #10
Hello,
Jerry Stuckle wrote:
No, I'm trying to direct you to the best possible resource for your
question. But you are too thick-skulled to understand it.
It's not yours or anybodys job to "direct" anybody else to something.
The idea of a newsgroup is: If you have something to say to answer the
question, say it, if not, stay quiet.
No, it's not "tightly connected to PHP". This is strictly HTML and
browser behavior.
Nonsense, obviously you have not read my description.
If it was pure HTML, the same link would fetch the same content and
thus render the same page.
The whole question only makes sense with a server application.
This would be exactly the same if the header were
generated in PHP, Perl, VBScript
Okay. So now it's PHP.
.. or even HTML itself.
HTML cannot generate HTTP-headers like the header()-function does.
You don't know what you're talking about.
No, it was not a good choice. Look how many answers you've gotten.
The thread was poisoned by an arrogant wannabe.
So, sad enough, we can merely expect people with a constructive
attitude to join in (any more).

Sep 19 '06 #11
bvdb wrote:
Hello,
Jerry Stuckle wrote:
>>No, I'm trying to direct you to the best possible resource for your
question. But you are too thick-skulled to understand it.


It's not yours or anybodys job to "direct" anybody else to something.
The idea of a newsgroup is: If you have something to say to answer the
question, say it, if not, stay quiet.
No, it's not my "job". However, I do try to help people. If it's
something pertinent to this group and I can handle it, I do. If it's
pertinent to this group and I can't, I let someone else. And if there
is a better group to ask the question in, I try to steer the person that
way, even if he being an arrogant asshole.
>
>>No, it's not "tightly connected to PHP". This is strictly HTML and
browser behavior.


Nonsense, obviously you have not read my description.
If it was pure HTML, the same link would fetch the same content and
thus render the same page.
The whole question only makes sense with a server application.
Not at all. Something on the server that is completely independent
(i.e. a cron job that runs every 10 seconds) can replace the HTML pages
between requests from the browser. The same link would retrieve
different content every 10 seconds. But it would be static HTML.
>
>>This would be exactly the same if the header were
generated in PHP, Perl, VBScript


Okay. So now it's PHP.
Right. It's generated by PHP. But the problem is not a PHP problem.
>
>>.. or even HTML itself.


HTML cannot generate HTTP-headers like the header()-function does.
You don't know what you're talking about.
Actually, I do. Apache/IIS can and does generate EXACTLY the same type
of headers as PHP does. To an IP trace sometime and figure it out. The
only difference is that these headers are preset in the httpd.conf file.
But I doubt you know anything about that.

Unlike you, I've been dealing with webserver intimately for around 15
years - including internals. I know *exactly* what I'm talking about.
>
>>No, it was not a good choice. Look how many answers you've gotten.


The thread was poisoned by an arrogant wannabe.
So, sad enough, we can merely expect people with a constructive
attitude to join in (any more).
Not at all. It was someone who didn't know what newsgroup to ask it in.
There is nothing stopping anyone else from responding.

I'll expect the apology when you get your answer and find it's not a PHP
problem at all. But I know I won't get it. Guys like you never do.

Go ahead - spin your wheels. I don't need to put up with your asinine
abuse. So much for trying to help a complete idiot.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 20 '06 #12
Jerry Stuckle schrieb:
....
No, it's not my "job". However, I do try to help people.
"Help", hmm. Go out and do some real help.
The whole question only makes sense with a server application.

Not at all. Something on the server that is completely independent
(i.e. a cron job that runs every 10 seconds) can replace the HTML pages
between requests from the browser.
:-))
HTML cannot generate HTTP-headers like the header()-function does.
You don't know what you're talking about.

Actually, I do. Apache/IIS can and does generate EXACTLY the same type
of headers as PHP does.
Yes, of course, but it is not directed by the HTML code.
And HTML code is what a HTML newsgroup is about.
So much for trying to help a complete idiot.
So you learned something in the end. Fine.

Sep 20 '06 #13
bvdb wrote:
Jerry Stuckle schrieb:
...
>>No, it's not my "job". However, I do try to help people.


"Help", hmm. Go out and do some real help.
I do. Every day. But some people are just too think skulled to accept it.
>
>>>The whole question only makes sense with a server application.

Not at all. Something on the server that is completely independent
(i.e. a cron job that runs every 10 seconds) can replace the HTML pages
between requests from the browser.


:-))

>>>HTML cannot generate HTTP-headers like the header()-function does.
You don't know what you're talking about.

Actually, I do. Apache/IIS can and does generate EXACTLY the same type
of headers as PHP does.


Yes, of course, but it is not directed by the HTML code.
And HTML code is what a HTML newsgroup is about.
Actually, it is. But you wouldn't understand that.
>
>>So much for trying to help a complete idiot.


So you learned something in the end. Fine.
Yea, I learned to dump you in the bozo bin. So long, bozo.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 20 '06 #14
Hmm .. I don't think your problem is the caching at all. But you
didn't supply any code to us so we could actually see it for ourselves.
But curious as I was, I put together a simple example that would show
how someone might accomplish this. Granted there may be much better
ways to accomplish this ... but:
frames.html
---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD><TITLE>PHP Frame Example</TITLE></HEAD>
<FRAMESET cols="20%, 80%">
<FRAME src="links.html" name="links_frame">
<FRAME src="detail.php" name="details_frame">
</FRAMESET>
</HTML>
---
links.html:
---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>

- <a href="detail.php?id=1" target="details_frame">Row 1</a><br>
- <a href="detail.php?id=2" target="details_frame">Row 2</a><br>
- <a href="detail.php?id=3" target="details_frame">Row 3</a><br>
- <a href="detail.php?id=4" target="details_frame">Row 4</a><br>
- <a href="detail.php?id=5" target="details_frame">Row 5</a><br>
- <a href="detail.php?id=11" target="details_frame">Row 11</a><br>
- <a href="detail.php?id=12" target="details_frame">Row 12</a><br>
- <a href="detail.php?id=13" target="details_frame">Row 13</a><br>
- <a href="detail.php?id=14" target="details_frame">Row 14</a><br>
- <a href="detail.php?id=15" target="details_frame">Row 15</a>

</body>
</html>
---
detail.php:
---
<?php
//need a session to store which ones are already highlighted
session_start();
$set=$_SESSION['set'];

//see if anything was given to highlight/de-highlight
if(isset($_GET['id'])) {
//see if the id is already set
$pos = strpos($set, ':'.$_GET['id'].':');
if($pos === false) {
//not in the string so put it there
$set .= ':'.$_GET['id'].':';
} else {
//in the string so remove it
$set = str_replace(':'.$_GET['id'].':',"",$set);
}

//now update the session
$_SESSION['set']=$set;
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>

<style type="text/css">
.h { background-color:#CCCCFF; }
</style>

<table border="1" cellpadding="3" cellspacing="0">
<tr<?php echo strpos($set, ':1:') !== false ? " class='h'" : '';
?>><td>Row1</td><td>value1</td></tr>
<tr<?php echo strpos($set, ':2:') !== false ? " class='h'" : '';
?>><td>Row2</td><td>value2</td></tr>
<tr<?php echo strpos($set, ':3:') !== false ? " class='h'" : '';
?>><td>Row3</td><td>value3</td></tr>
<tr<?php echo strpos($set, ':4:') !== false ? " class='h'" : '';
?>><td>Row4</td><td>value4</td></tr>
<tr<?php echo strpos($set, ':5:') !== false ? " class='h'" : '';
?>><td>Row5</td><td>value5</td></tr>
<tr<?php echo strpos($set, ':11:') !== false ? " class='h'" : '';
?>><td>Row11</td><td>value11</td></tr>
<tr<?php echo strpos($set, ':12:') !== false ? " class='h'" : '';
?>><td>Row12</td><td>value12</td></tr>
<tr<?php echo strpos($set, ':13:') !== false ? " class='h'" : '';
?>><td>Row13</td><td>value13</td></tr>
<tr<?php echo strpos($set, ':14:') !== false ? " class='h'" : '';
?>><td>Row14</td><td>value14</td></tr>
<tr<?php echo strpos($set, ':15:') !== false ? " class='h'" : '';
?>><td>Row15</td><td>value15</td></tr>
</table>

</body>
</html>
---
(This can be viewed at
http://www.eadexchange.com/test/frames/frames.html)

Seems to work fine for me and I don't see any caching issues at all.

So perhaps if you post some code, we can see what you have going on,
and then we may be able to help you. Generally you should always come
up with a simple example that highlights your problem. Because from
just reading your post, (I hate to say it) it doesn't look like a php
problem. Unless your script is jacked, in which case we would need to
see the code.

Another reason that making a simple example is a good idea: I can't
remember how many times in making a simple example, I've solved my
problem. Also people don't have to try and guess what's going on.

One problem you might want to look at is where you are starting your
session (if you're using one, which we wouldn't have to guess if you
supplied example code). It needs to be the first line of code you
execute and come before any html is printed out. In other words you
can't to this:
<html><head>
<?php session_start(); ?>
.....

Sep 20 '06 #15
Hello,
ctiggerf schrieb:
Hmm .. I don't think your problem is the caching at all. But you
didn't supply any code to us so we could actually see it for ourselves.
But curious as I was, I put together a simple example that would show
how someone might accomplish this. ...
Thanks. Yes, this is what I'm basically doing, only that I use a
session object to store the variables.
I tried the single window from your sample:
http://www.eadexchange.com/test/frames/detail.php?id=1

and it toggles the color on and off - as does my code. Only your code
still works in the frame context, mine does it only once.
This is why I assume the problem is connected to caching.

Anyway, I will reduce my code to the simplest form and either post the
solution or the question here again.

Sep 20 '06 #16

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

Similar topics

1
by: Donald Thompson | last post by:
How do I prevent the output of a user defined function from going to the browser? In my script I do something like: $MyVar = MyFunction($var1,$var); which works, except that the output from...
5
by: Bruce | last post by:
I have a number of forms that do significant work based on variables POSTed from the form. What is the common method of detecting and preventing this work from being done when the form is POSTed as...
7
by: Matt | last post by:
I have an interactive web page that I need to prevent refreshes on. The problem is that I want to ALLOW resubmissions, but only via the submit button. My web page has two forms on it, one form for...
2
by: BenM | last post by:
Description: I would like to prevent a user from logging in with their user/password combination on a different computer or even a different browser window, if they are already logged in. I have...
8
by: CJM | last post by:
How do people go about preventing the user from submitting a form for a 2nd time? For example, the user submits a form, clicks on the back button, and the submits the form again. I have used...
8
by: alanstew | last post by:
With the body tag calling out 'window onload', a function with a 'window.open' fails at the 'window.open' line. If I cut out the body tag, the function executes as normal. At first I thought it...
3
by: PSERVE | last post by:
Is the a way of preventing popups from other sites while your page is loading? -- Regards Nik http://www.itconsultancy.org
1
by: Wayne Aprato | last post by:
Is there an effective method of preventing users from accidentally or maliciously deleting the database file/files from a shared network drive? At the moment, I'm using a batch file to copy the...
10
by: Oleg Konovalov | last post by:
Hi, I have a Java GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks...
2
by: pingalkar | last post by:
In my application, on one form i m getting information from user and save this information , after saving this information again we loading that page. (At this moment if any one try to refresh this...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
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
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.