Connecting Tech Pros Worldwide Forums | Help | Site Map

Generated file

Andrew Clark
Guest
 
Posts: n/a
#1: Nov 27 '05
Hello,

I am 99% sure that the problem I am having is not PHP related, but to
remove my doubt, I am posting here.

I have a search page (interfacing with MySql) that displays results in an
IFRAME on the search page. I did this so the whole page would not have to
be reloaded on each query.

Each time I query the DB, I write the result set to a file and include this
file as javascript source on the results page. Up to this point everything
works fine, which is why I say I don't think this is PHP related.

I use javascript to "walk" the recordset. In internet explorer (only), the
first query recordset is all that is ever seen by the search page, even
though the javascript source file is correctly generated. Maybe this is a
little opaque so I will give an example.

search.html
--
<IFRAME NAME="dataiframe" SRC="blank.html"></IFRAME>
[...]
<FORM ACTION="display.php" METHOD="post" TARGET="dataiframe">
<INPUT TYPE="submit">
</FORM>

display.php
--
session_start ();
$filename = "tmp/" . session_id () . ".js";

// write recordset...
// include here
echo "<SCRIPT TYPE=\"text/javascript\" SRC=\"$filename\">

--
This file is always generated correctly. The problem arises when the
browser (IE) does not use the updated values in $filename. It is my belief
that IE caches the values in this file and when the frame is reloaded, IE
tries to be "smart" and sees that I am including the same file, and
therefore does not reload from the file but from its cache.

Now that I think about it, since the file is being correctly generated,
this is 100% NOT PHP related. Could someone shed light on this anyway? It
would be much appreciated.

Thanks,
Andrew

Alvaro G. Vicario
Guest
 
Posts: n/a
#2: Nov 27 '05

re: Generated file


*** Andrew Clark escribió/wrote (Sun, 27 Nov 2005 18:36:37 +0000):[color=blue]
> It is my belief
> that IE caches the values in this file and when the frame is reloaded, IE
> tries to be "smart" and sees that I am including the same file, and
> therefore does not reload from the file but from its cache.[/color]

I don't whether IE obeys date headers but you can tag the script document so it expires inmediately:

header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()-86400*365*10) . ' GMT');
header('Expires: ' . gmdate('D, d M Y H:i:s', time()-86400*365*10) . ' GMT');


// HTTP/1.1
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);

// HTTP/1.0
header('Pragma: no-cache');


BTW, have you remembered to set the appropriate Content-Type header?

--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Csaba Gabor
Guest
 
Posts: n/a
#3: Nov 28 '05

re: Generated file


Besides the comments of Alvaro on cacheing, you can see some additional
comments at http://php.net/imagecreatefrompng.

Another technique some people use (which I don't recommend for
production, but may be OK for testing) is to append a dummy query
string to the end of the main page with a random component: "?rubbish="
+ randomNumber(). This ensures that the page is not cached.

Csaba Gabor from Vienna

Andrew Clark wrote:[color=blue]
> Hello,
>
> I am 99% sure that the problem I am having is not PHP related, but to
> remove my doubt, I am posting here.
>
> I have a search page (interfacing with MySql) that displays results in an
> IFRAME on the search page. I did this so the whole page would not have to
> be reloaded on each query.
>
> Each time I query the DB, I write the result set to a file and include this
> file as javascript source on the results page. Up to this point everything
> works fine, which is why I say I don't think this is PHP related.
>
> I use javascript to "walk" the recordset. In internet explorer (only), the
> first query recordset is all that is ever seen by the search page, even
> though the javascript source file is correctly generated. Maybe this is a
> little opaque so I will give an example.
>
> search.html
> --
> <IFRAME NAME="dataiframe" SRC="blank.html"></IFRAME>
> [...]
> <FORM ACTION="display.php" METHOD="post" TARGET="dataiframe">
> <INPUT TYPE="submit">
> </FORM>
>
> display.php
> --
> session_start ();
> $filename = "tmp/" . session_id () . ".js";
>
> // write recordset...
> // include here
> echo "<SCRIPT TYPE=\"text/javascript\" SRC=\"$filename\">
>
> --
> This file is always generated correctly. The problem arises when the
> browser (IE) does not use the updated values in $filename. It is my belief
> that IE caches the values in this file and when the frame is reloaded, IE
> tries to be "smart" and sees that I am including the same file, and
> therefore does not reload from the file but from its cache.
>
> Now that I think about it, since the file is being correctly generated,
> this is 100% NOT PHP related. Could someone shed light on this anyway? It
> would be much appreciated.
>
> Thanks,
> Andrew[/color]

Closed Thread