How do I force an ajax/mysql update - cache problem

0 favourites
  • 2 posts
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • Hi guys,

    got a small problem with the game I'm creating.

    I'm making a text based game where you have to fight monsters and fulfill quests and stuff, but I got a problem with my sql data not being updated all the time.

    For example, I have a situation where you can battle another player. After the battle, the new troop counts of both players are send to an MySQL database through an Ajax command. This works without any problems as I can see the adjusted and correct values in the DB directly. The problem however, is that when I do another battle immediately, the 'old' troop counts still apply and not the adjusted ones from after the previous battle. There is an Ajax command before each battle, to reload the troop counts from the DB each time, but it seems that the browser still takes the cached values instead of the newly values.

    If I wait 5-10min, and the check the troop counts, the values are correct, so it seems that it's only 'refreshing' its data every X minutes...

    Anyone has an idea how to prevent or solve this?


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi ,

    Try to add these two lines in your php file to ignore cashing :

    header('Cache-Control: no-cache');

    header('Pragma: no-cache');

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)