0

I am working with XML on a site and each time I run a script to update the XML file, I have to change the subdomain (I've gone from "" to "www" to "fdasekjlfw" and so on) to have the refresh do anything. After about an hour, the update is seen regardless of the subdomain.

I'm wondering if I'm doing something incorrectly. It doesn't seem right to have to do this each time.

My web host is FatCow and the script was in PHP, if that helps.

Thanks

ADDITIONAL INFO:

I spoke with a fellow that uses the same server (different site though). He says he's had the exact same problem periodically when updating a MySQL db, and usually when changing an external CSS file (but not always). The scripts for both his and mine are PHP (no scripting with the CSS files though).

In my case, submitting a form sends about 4 files (images) and 10 variables to the script. I'm using the DOMDocument class to remove, add, and update. Here is one of the scripts used (they are all independent, but the same problem arises).

<?php

## Deletes shirt row ##

$delMark = $_GET['href'];
$doc = new DOMDocument; 
$doc->load('../xml/shirts.xml');
$docRoot = $doc->documentElement;

$shirts = $docRoot->getElementsByTagName('shirt');

$nodeToRemove = null;

// find the delete marker
foreach ($shirts as $domElement)
{   
  $attrValue = $domElement->getAttribute('href');

  if ($attrValue == $delMark) 
  {
    $nodeToRemove = $domElement;
    break;
  }

}

if ($nodeToRemove != null)
    $docRoot->removeChild($nodeToRemove);

// save to XML file
$fp = fopen("../xml/shirts.xml", wb);
fwrite($fp, $doc->saveXML());
fclose($fp);

?>

Thank you

Voriki
  • 1,617
  • 2
  • 19
  • 43
  • 1
    You definitely should not have to change the subdomain to effect a script. There must be some reason why it is caching - you may have to give far more information. – Orbling Jun 02 '11 at 00:40

1 Answers1

0

I know that XML files are usually cached in the browser. So the script is probably doing its job, but the XML is not being reloaded because of that. Perhaps you can change the script to append a querystring to the XML file, which should force a refresh (untested, so I am not sure this works). For example (although with css): Force refresh of cached CSS data

Community
  • 1
  • 1
Jason Gennaro
  • 34,535
  • 8
  • 65
  • 86
  • Hey Jason. You were right. I had to force a refresh of the XML. I have a Math.random() variable that is added to the URL of the XML file when loading it. That did the trick! – Voriki Jun 02 '11 at 01:21