如何防止浏览器/服务器端的数据缓存?

I'm primarily an Electrical hardware engineer with a very little knowledge in php, javascript and similar languages.

I'm building a system that will track my device in a real time and visually display current GPS position of it on a Google map. My device is able to properly send data about its position (latitude and longitude) as often as I want. GPS position data is sent using a HTTP communication protocol (GET requests) and is stored on a server side in a .txt file called gps.txt.

php script extracts data from that gps.txt file and displays them on a Google map.

Here is the script written in php (I applied my own API key for properly use Google maps).

This script runs on some free web hosting platform. Take a look here.

Now, the trouble comes when I call the script from my web browser. Namely, although a gps.txt data is properly refreshed with a fresh data, these new position markers are NOT displayed on the map. It seems that either my web browser or my web server are cashing some data and don't allow the script to run over a fresh gps.txt file.

I suppose that, for many of you web software guys out there, this is a trivial problem.

I also tried to prevent data cashing on my browser by including

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

in my script but with NO success.

Would you, please, give me any suggestion on how to overcome this situation and always have the latest GPS position displayed on my map?

Thank you very much for your time and effort to help me.

Sincerely,

Bojan

查看全部
douxie2023
douxie2023
2015/07/13 10:34
  • php
  • gps
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复