Hi there!
Is there a way to refresh the page to all users when one of them clicks on a button like in Cent Auctions ?
For example:
There is a button refresh and when I click it the page refreshes to all...

Dani AI

Generated

A short, practical summary that builds on the suggestions already posted: wants one user action to force a refresh for everyone on the same page. demonstrated a client-side reload (that only affects the clicking user). suggested polling (works but wastes CPU/network and scales poorly). For a reliable, real-time “refresh-all” you want server‑push rather than a per‑client timer.

Typical, robust workflow (push-based)

  • Each client opens a persistent channel (WebSocket or Server‑Sent Events).
  • When a user clicks the refresh button the browser notifies the server (HTTP POST or socket emit).
  • The server validates/authorizes the request and broadcasts a short “refresh” message to all connected clients.
  • Clients receive the message and either reload the page or, better, patch only the changed parts of the DOM to avoid a full reload.

Minimal Socket.IO example (server and client):

/* server.js (Node + Socket.IO) */
const express = require('express');
const http = require('http');
const socketIo = require('socket.io');

const app = express();
const server = http.createServer(app);
const io = socketIo(server);

app.post('/trigger-refresh', (req, res) => {
  io.emit('refreshAll');
  res.sendStatus(200);
});

io.on('connection', socket => {
  // optional: auth or room join logic
});
server.listen(3000);
/* client.js */
const socket = io();
socket.on('refreshAll', () => {
  // reload or update the page
  location.href = location.href;
});

Practical cautions and troubleshooting

  • Avoid forcing full reloads when a partial update would do; full reloads disrupt users and increase load.
  • Add permission checks and rate‑limiting on the server so a single user cannot spam refreshes.
  • If you run multiple app servers, use a pub/sub (Redis) or Socket.IO adapter so broadcasts reach all instances.
  • Common failures: WebSocket blocked by proxies, missing sticky sessions behind a load balancer, or wrong CORS/origin settings. Add reconnect/backoff logic and a fallback (long polling or SSE) for older environments.

Recommended Answers

All 4 Replies

I really don't understand what you are trying to achieve here!
But you can refresh the page with this bits of code:

<input type="button" value="refresh" onclick="window.location.reload();" />

I'll try to explain it.
We have a button "Refresh" (For example), when someone clicks that button the page refreshes but not only to him, but to all users on that page. Is that more cler ?

Try this one instead

<input type="button" value="refresh" onclick="window.opener.refresh();" />

to note that this will only work with windows that are in the same domain...

Member Avatar for Member #210412

try to send a http request to server periodically and check the version number. if the version on client side less then the server side, refresh the page... dont forget to increase the version each time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.