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

Get help using Construct 2

Post » Fri Aug 11, 2017 8:22 am

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? :geek:

Thanks.
B
5
Posts: 6
Reputation: 242

Post » Fri Aug 11, 2017 11:10 am

Hi ,
Try to add these two lines in your php file to ignore cashing :
header('Cache-Control: no-cache');
header('Pragma: no-cache');
B
18
S
8
G
2
Posts: 48
Reputation: 2,504


Return to How do I....?

Who is online

Users browsing this forum: David181, Shenkai the ssj and 22 guests