EASYPHP 1.8 based PHP script on Apache and IE 6 - end-to-end system is periodically cacheing XML files read by script

I installed the latest version EasyPHP (Version 1.8) and developed a small application in PHP.
It is running on EASYPHP's Apache 1.3.33.
It needs to be used with Internet Explorer (Version 6) due to a component it uses.

The PHP program parses a specific XML file (say 321.xml) generated by another application with content periodically re-written by the generating application.

The PHP program is launched as follows:

      http://1.2.3.4/myapp.php?F=321

where 1.2.3.4 is replaced by the actual IP address or domain name, and
the XML file name to be processed is 321 (in this example) - actually 321.xml

The PHP script accesses and parses the correct XML file, however often the system "fixates" on an old XML file's content - as if there was caching taking place somewhere in the system.
Equally puzzling, at times the system suddenly starts processing the fresh/current (up-to-date/correct) XML file content.

Tried entering

      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="refresh" content="3">
      <META HTTP-EQUIV="Expires" CONTENT="-1">
      <META HTTP-EQUIV="Pragma" CONTENT="no-cache">

into the PHP file and edited the httpd.conf Apache file to prevent caching, but it does not seem to help.
Perhaps I missed something which still allows caching of the XML file.

a) Would appreciate advice on how to handle this - or at least how to approach debugging the problem

b) Does anyone know what is the difference between the "httpd.conf" in
      C:\Program Files\EasyPHP1-8\conf_files
and      C:\Program Files\EasyPHP1-8\apache\conf

c) Can TELNET, Apache log file or other tool be used to view the "response headers" and actual XML file content transmitted to the browser by the server - for debugging this type of problem? If so then how?

Thank you for the help
pfefferlAsked:
Who is Participating?
 
Richard QuadlingSenior Software DeveloperCommented:
If the XML file is fully formed (i.e. If the url had been www.site.com/file.xml) and that is all that is needed then ...

<?php
if ( isset($_GET['F']) && file_exists('./' . $_GET['F'] . '.xml') )
      {
      header('Content-type: text/xml');
      header('Content-length: ' . filesize('./' . $_GET['F'] . '.xml'));
      $fp_xml = fopen('./' . $_GET['F'] . '.xml', 'rb');
      fpassthru($fp_xml);
      exit;
      }
?>
0
 
Richard QuadlingSenior Software DeveloperCommented:
Hi pfefferl,


e.g.

<?php
$s_append = microtime(True);

echo <<< SOME_HTML
<meta http-equiv="refresh" content="3;url=./{$_SERVER['PHP_SELF']}?F={$_GET['F']}&time=$s_append">
SOME_HTML;
?>

sort of thing.



Regards,

Richard Quadling.
0
 
pfefferlAuthor Commented:
Dear Richard,
a) what is the effect of above code?
Thanks,
Larry
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Richard QuadlingSenior Software DeveloperCommented:
To supply a seemingly random parameter to the request. This will stop the browser from getting the same data as the URL is different.

e.g.

url = myapp.php?F=123

vs

url = myapp?F=123&12345
url = myapp?F=123&12346
url = myapp?F=123&12347
url = myapp?F=123&12348
url = myapp?F=123&12349

The value is junk, but is different every microsecond.
0
 
pfefferlAuthor Commented:
Thanks. I can see how this prevents getting the same Web page.

Does this also prevent reading a cached XML file?

The file name is passed to the PHP script via something like
      http://1.2.3.4/myapp.php?F=321

where 321 is the XML file prefix and is pased to the PHP script. The actual XML file is read via
       xmlDoc.load(.....)
within the script
0
 
Richard QuadlingSenior Software DeveloperCommented:
The content of the http request is irrelevant.

Ah.

Hold on.

Are you saying that when the user (or their browser) makes the request, you eventually get a parameter which contains 'http://1.2.3.4/myapp.php?F=321'

or

are you looking at $_GET['F']  to get the name of the file?

If the first one, then you will need to strip off everthing from & onwards.

I'm a PHP ZCE, so you can talk PHP if you want.

Though you would be better off talking in the PHP section -> http://www.experts-exchange.com/Web/Web_Languages/PHP/
0
 
pfefferlAuthor Commented:
Dear Richard,

The script is launched by an address string (URL & prameters) such as
      http://1.2.3.4/myapp.php?F=321
and the XML file name prefix (e.g. 321) is obtained via $_GET['ID']

The correct XML file IS opened by the PHP script.
The only problem is that sometimes, for extended periods, the cached content is obtained.
I thought that the Apache cache disabling parameters in httpd.conf will prevent this, but apparently there is still some caching.

Added note. The PHP file/Web page
        http://1.2.3.4/myapp.php 
is refreshed every few seconds and polls for new content in the XML file.

If I change the "address string" to
http://1.2.3.4/myapp.php?F=321

RE: PHP talk --- I am experienced programmer in many languages, but am more or les a novice in PHP .... (for now)

Thanks,
Larry
0
 
pfefferlAuthor Commented:
PS

If I change the "address string" to
   http://1.2.3.4/myapp.php?F=321&xxxx
where xxxx is a random string, would that prevent the XML file caching?

Larry
0
 
Richard QuadlingSenior Software DeveloperCommented:
Yes.

The entire URL is used for caching.
0
 
pfefferlAuthor Commented:
Just to be sure I understand:
adding a random string to the tail end of the URL will also prevent reading cached content by xmlDoc.load(.....)?
0
 
Richard QuadlingSenior Software DeveloperCommented:
Be careful, the random string applies to the browser not looking at its cache for a copy of a previous request.

If the PHP script then goes and gets more data from somewhere, this is the place where the issue lies.

You've made me wonder where the issue is.

What is the full request for the browser?

Can you show the script you are using to run this?
0
 
pfefferlAuthor Commented:
Full request for the browser:
      http://1.2.3.4/myapp.php?F=321

I'll try to smiplify the PHP file and send it. It is a mix of HTML, PHP and Javascriot and the XML fle is loaded via
loadStatus = xmlDoc.load(filename)
0
 
pfefferlAuthor Commented:
--- Continbued ---
.. which is a Javascript command

0
 
Richard QuadlingSenior Software DeveloperCommented:
Ah. So the issue is in the JavaScript XML loader!!!!

Sort of AJAX.
0
 
Richard QuadlingSenior Software DeveloperCommented:
So the request from the xmlDoc.load with the filename containing the random additional parameter ...

http://1.2.3.4/myapp.php?F=321&1234567

Will be a unique request each time.

The issue is getting the browser to get the new random string each time.

You MAY be better off using the browser to construct the random element rather than supplying it.

If the browser IS cacheing, the page will make the same request via xmlDoc.load()!

You could use a javascript timer to do the refresh, saving a round trip for the entire page which only really wants the XML data updated.

Obviously, you will need client side JS to clear the display and redraw the new XML data as appropriate, so maybe not saving anything in effort.
0
 
pfefferlAuthor Commented:
a) What is "AJAX"?

b) currently xmlDoc.load gets a parameter like
       xmlDoc.load('321.xml')
   or IP address qualifierd as
       xmlDoc.load("http://1.2.3.4/321.xml")

and NOT
       xmlDoc.load((http://1.2.3.4/myapp.php?F=321&1234567")

    The xmlDoc.load sems to be related to the caching problem.
    I suspect, but can't as yet tell, that this may be due to the Apache server

c) "If the browser IS cacheing, the page will make the same request via xmlDoc.load()!"
   REquesting the same FILE NAME should not be a problem, in fact it must be so.
   Only the file CONTENT changes

d) Using the Javascript timer may be a good idea - I'll look intio that
0
 
Richard QuadlingSenior Software DeveloperCommented:
Where does you myapp.php come into it then?
0
 
Richard QuadlingSenior Software DeveloperCommented:
AJAX = Asynchronous JavaScript with XML.

Also known as Web V2.0


It is the new way of writing web apps where there is no page refreshing, just a constant communication between the browser and the server behind the scenese and the browser updating the page in real time. Automatically.

Very nice tech.

Like a GUI is in real time - the code can say change this button to disabled because a DB value says so.

Currently you would have to do a refresh to get a new page.

With AJAX the communication says that the button is disabled, so the browser makes it so.

AJAX is a concept, not a library of code.

AJAX has been implemented in MANY languages.

Do a gogle.
0
 
pfefferlAuthor Commented:
a) Thanks for AJAX info. Will look into it

b) "Where does you myapp.php come into it then?"
It issues the  xmlDoc.load and if the parameters changed since last poll then it changes things on the display.

Imagine the application is a dynamic display of chess board in a tournamemt.
MyApp then draws the chess board and sets up the pieces in initial order.
Then it polls for "moves" by Black or White and if a new move was made then it re-draws the board as needed.
0
 
Richard QuadlingSenior Software DeveloperCommented:
So how did it all go?
0
 
pfefferlAuthor Commented:
a) I tested the application without any changes and now it doesn't cache - i.e. it works. That is normally good but in this case there may be an "intermittemt caching problem" (sometimes caching and sometimes not) and that is more difficult to resolve. Sort of like certian problems in real-time systems where problems can be intermittent. If the problem persists I suspect ther may be another system between the Apache server and the IE browser. One possible suspect is a firewall - I have to speak to its administrator to see if it can somehow intermittently cache. As far as I understand Apache parameters in its control file (httpd.conf) prevent caching by proxy servers - which I firsdt thought may be the problem What is really puzzling (so far) is the intermittent nature of caching.

b) So far not clearwhat change to make to the PHP/Java scripts to further prevent caching. Your suggestion is good and sounds like it would prevent cached loading the PHP file (Myapp.php). Do you think it would also have an effect on the  xmlDoc.load function - and somehow cause it and the unerlying mecahnisms to prevent caching? If so I will try your suggestion if the system caches again XML file loads
0
 
Richard QuadlingSenior Software DeveloperCommented:
The way to get xmlDoc.load to work is to use the same mechanism.

Would this be suitable ...

xmlDoc.load('http://www.yoursite.com/getanXML.php?F=123&randomjunk');


The getanXML.php file will return the XML file.

What I'm not sure of is where the xml data is. You don't have to ASK for a .xml file. You make a request and the response is XML for the xmlDoc.load() function.

In PHP, you would use the header() function to set the appropriate content-type header and then send the XML data.

0
 
pfefferlAuthor Commented:
Hi Richard,

The XML file is in same directory on the Web seerver as the myapp.php script

If I understand correctly you suggest:

1) writing a PHP script called getanxml.php

2) refering to it in myapp.php by
       xmlDoc.load('http://www.yoursite.com/getanXML.php?F=123&randomjunk');
    where 123 is the XML file prefix

3) getanxml.php would read the XML file and would return it to myapp.php via header()

If you think this could prevent caching of XML file reads I'll try it if the cache problem comes up again.

How would getanxml.php read the XML file. Also via xmlDoc.load?

Thanks for the patient help.

Larry
0
 
pfefferlAuthor Commented:
Richard,
Sounds good & will try it.
Thanks for the help!
Larry
0
 
Richard QuadlingSenior Software DeveloperCommented:
NP.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.