Jump to content

Writing XML - Apache Server - AJAX


SchweppesAle

Recommended Posts

Hi, I'm using AJAX to execute a script every time a user visits the page.  The script reads an xml file then tallies the counter for each page view, however I'm a little worried about multiple users reading the file then adding one to the counter. 

 

Ex:

User1 sees the counter set to 2

User2 sees the counter set to 2 then adds 1 = 3

User1 adds 1 to counter = 3(instead of 4). 

 

I guess my concern is that users will be reading and writing to this file synchronously rather than asynchronously.  Should this be an issue?

Link to comment
https://forums.phpfreaks.com/topic/178518-writing-xml-apache-server-ajax/
Share on other sites

Use a database for this instead, and log every visit as a single row in a table. It's far better for statistics

 

that was my original intention...won't this cause too much strain on the server though?

 

AJAX is used to execute the script for each banner on our site. 

 

Meaning if we choose to display 6banners, that's 6 queries for every page view.  I figured I could reduce this substantially by storing each entry into an xml file then setting up a cron job to read and store the entries within our db. 

 

Just not at all sure if the fwrite() and fread() functions are configured to access files asynchronously.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.