XML files not updating on web page

I have several pages that import data from xml files. The data does not refresh when a changed xml file is uploaded. It seems to be using some kind of cashed data from old file.
How can I fix this?

You should clear your cache, you said it yourself:

Read this article:

1 Like

It’s not my browser cache. It’s something on the server side.

The problem is not my browser cache. It seems to be on the server side.

Can you please provide a bit more information, or reproduction steps?

How does the code even work? You say the data is fetched from XML files? How does that work? Do you upload an XML file with FTP and is it read with PHP code? Or does it work in another way? Can you point us to a place on your website where we can see this in action?

1 Like

I upload several XML files. Each web page has code to read it’s specific XML files and load the data into HTML tables in the web page.
For instance - web page for “player stats” (PlayersMonthly.html) uses 3 xml files. uDates.xml to load current date info… uPlayersMonthly.xml to grab players monthly stats, and uPlayersYearly.xml to load load player’s year-to date data. All the xml files are written by an excel spreadsheet used to compile daily stats. Then the xml files are uploaded to site with FTP. The XML file names DO NOT CHANGE. Only the data in the file changes. Therein I believe is the problem. Upon 1st run the site loaded all the xml files fine. When the xml file data changes, the web pages still only use the data from the 1st xml file reads. Not the new data. I suspect there is something caching the 1st xml file read and then not realizing the data has changed.(It’s NOT my browser cache.) Normally I would suspect coding error, however the same pages work fine on my computer and worked fine on our previous two sites that went belly up.
I attempted deleting the uFiles before uploading them again but made no difference.
Code that inserts uPlayersMonthly.xml into PlayersMonthly.html
Load xml code:

var x=xmlDoc.getElementsByTagName("tabledata");
Looping Code to insert xml data into HTML table in page.
for (i=0;i<x.length;i++)
<!.................and so on.>

Feel free to edit the the data in uDates.xml and uPlayersMonthly.xml. for any testing.

Ah, right, the XML data is being read by Javascript code.

This changes things a bit because now browser caching takes effect. Our servers return quite aggressive cache settings so browsers don’t download the same files for every page. Generally, this is good because it speeds up your site and reduces hits and bandwidth usage.

But browsers are also instructed to cache XML files for one month, which is why your browser doesn’t fetch the latest data.

To fix this, I created a file with the name .htaccess and the following content:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType application/xml "access 1 minute"
    ExpiresDefault "access 1 month"

This means everything is cached for 1 month, except for XML files, which are only cached for 1 minute.

With this, the changed data should be visible within a minute after uploading.


hmmm I’m in way over my head here. Some background - This is a very small site used by at most 50 people and on a normal basis 15 people. The site is merely a way for card players to check their stats. Most exit the site within 5 minutes. Bandwidth and hits are VERY low.
Nobody maintaining the site is any kind of programmer other than html to some extent.
So, what do I do with file .htaccess`? If nothing, then it still does not work.
Maybe some better way to do this?

I already set this for you. If you open the file manager and go to the htdocs folder, you’ll see a file with the name .htaccess with this content.

This should have solved the problem as far as I can tell. Can you try changing the data and then checking again after a few minutes? The files are still cached for 1 minute.

If even that’s too much, you can replace the access 1 minute with access 0 seconds too I think. That will completely disable caching.

1 Like

Dosen’t it have to be “1 minutes”? Correct me if I’m wrong.

In my own testing, 1 minute was correctly converted to a cache TTL of 60 seconds. Perhaps both works?

Thanks, but the pages still do not work. Even forcing the browser to override cached pages with a Ctrl+Shift+R refresh. I tried to upload an edited…htaccess but it won’t let me. I’m thinking the html pages have to be set to a 1 minute cache also. I’m guessing the html pages are still using the cached version, which in turn are no are not forcing the .xml file to be called for a reload. Also our html pages change at least once a month, usually more often. Not all of them but just some.

if I understood this sentence well
you need to put the .htaccess file in the htdocs folder (don’t try to edit the main one that is outside of that dir)

you can also edit your .htaccess file online with monstaFTP (file manager) from the client area

btw. you can use this “code” as a temporary test version :


The HTML page may be cached, but that’s not an issue. It will only cache the HTML content that’s sent by the server, not the content that’s created after executing the Javascript. The Javascript code itself sent from the server is likely also cached, but only the code itself, it’s still executed on every page.

I don’t know how well the Ctrl+Shift+Refresh works here. Could you please try opening the site in private browsing mode and see if the data changes there? Private browsing is the best way to go around all caches in your browser.

1 Like

OK time out. I checked the data in the xml files and they are all old. The tourney host forgot to upload files for Oct 7. He reloaded old files of oct 6. I’ll get hold of him later tonight and will check after he loads again.

Back. We had 3 people testing using 3 browsers each for 4 days. We changed data daily. It wasn’t pretty. some pages worked, some didn’t, The two pages that each used two xml files each would be correct for 1 table and not the other.
Last hope is change .htaccess to both xml and html with a time of 0. I tried, but the file won’t let me edit it, or upload an edited file.

Note that changing the .htaccess code only changes the cache settings for people who don’t have a cached version of the file yet. If the other people testing still have an old XML file in their browser cache which is set to be cached for a long time, they will keep using it until their cache expires or is cleared in another way.

Please make sure to edit the file in the htdocs folder. Not the file in the root directory that says “DO NOT EDIT THIS FILE”. Because guess what, you cannot edit that file.


Thank you for your help. The only thing that works is visitors must use incognito window.

if it helps you (look at the word cache on/off )

or probably easier to switch website to PHP


Ty, really appreciates the help. We are a bunch of 70+ year old card players just trying to display player’s stats. We realize that our web page coding is probably 20 years out of date, To that end we have some members taking your suggestion and learning PHP.Wish us luck :wink: