Jan Henriksen
Jan Henriksen

Reputation: 19

How to refresh a webpage remotely on other computers

Lets say I have PC 1 and PC 2. PC 1 is located in Norway and PC 2 is located in USA. www.webpage.com is currently open on the web browser on PC 2.

Now on PC 1, I will change the background on the www.webpage.com color to red. I will change the css and save it using example ftp. So the question is, how can I make the PC 2 to change color without having someone to sit beside the computer and refresh the page.

How can I remotely tell the server to refresh the website?

Upvotes: 0

Views: 3530

Answers (1)

Datadimension
Datadimension

Reputation: 1045

To sketch out I would encode a 'pageversion' from php into the javascript on the initial page load:

var pageversion=<?php echo $pageversion ?>;

Then use EventSource

eventer = new EventSource("/eventeg.php");
eventer.onmessage = function (event) {
   var datasent=event.data;
   //use data to compare versions and then reload
};

Where the server sends data through a keep-alive connection - simply have the server update the version it sends in realtime and if un-equal do what you need - eg warn the user then have it force refresh after a timeout. The reload will then align the versions. You might want to use http-refresh as well as a backup for javascript failure.

Upvotes: 1

Related Questions