I am writing a HTML application for an Arduino-based web server using only C and C++ on the Arduino webserver and HTML only on the client web browser.
The index page is a simple form containg two radio buttons and a 'Submit' button BUT at the top of the page is the encoded day and date extracted from a real-time clock chip attached to the Arduino.
I want to re-transmit the entire page ( < 400 bytes) every 5 seconds with an updated time.
I have no trouble encoding and transmitting the encoded page the first time but thereafter the browser just sits displaying the original page with the original time, even though debugging printout from the Arduino says that it is transmitting a new page every 5 seconds.

How do I get the Arduino to tell the Browser to forget the last index page and receive a new one - using HTML only?'

Dani AI

Generated

A short, practical addendum to the thread: was right to point toward an HTML refresh and confirmed it works for a very small page. Two technical reasons explain why an Arduino "re-sending" HTML may appear to do nothing: browsers only render responses to client requests (they do not accept unsolicited pushes), and caching or an improperly terminated HTTP response can make the browser keep the original page.

Three robust options, ordered from simplest to best practice:

  • Meta refresh (HTML-only, simplest). This reloads the whole page every N seconds but also reinitializes the form and can trigger a "resubmit" warning if the page arrived via POST.

    <meta http-equiv="refresh" content="5">
  • Tell the browser not to cache the response (server-side headers). Ensure the Arduino prints these headers before the HTML body and closes the connection so the browser treats each reply as a fresh response:

    HTTP/1.1 200 OK
    Content-Type: text/html; charset=utf-8
    Cache-Control: no-cache, no-store, must-revalidate
    Pragma: no-cache
    Expires: 0
    Connection: close
    Content-Length: <length>
  • Update only the clock with a lightweight client poll (smooth UX). If JavaScript is acceptable, expose a tiny /time endpoint from the Arduino and poll it every 5s:

    <span id="clock">--:--:--</span>
    <script>
    setInterval(function(){
    fetch('/time').then(r=>r.text()).then(t=>document.getElementById('clock').textContent = t);
    }, 5000);
    </script>

    This avoids full-page reloads and preserves form state. For real-time updates with less polling, consider Server-Sent Events or WebSockets only if the Arduino build can support them.

Troubleshooting tips: use browser DevTools Network to confirm whether new requests are being made and inspect response headers/status (304 indicates caching). If responses are requested but the body never changes, check Content-Length/Connection handling on the Arduino. For a quick cache-bust without changing headers, include a timestamp in the URL (e.g., index.html?ts=...) so each reload fetches a unique resource.

Recommended Answers

All 3 Replies

My classic understanding of this is you can't just send a new page and the browser update. So let's step back to how a browser in the most simplest way works. For simplicity the browsesr is called "browser" and your web server is called "server."

Browser starts up and you type in some URL. Then the request is made and the server responds. Server sends the HTML and once the end is done, anything else is ignored by the browser.

So how to update in 5 seconds? In your server, replies in the HTML code to reload the page in some number of seconds. Try the refresh code such as http://www.beansoftware.com/HTML-CSS-FAQ/Refresh-Page-After-X-Seconds.aspx

There are more advanced ways that you would code up, but let's go with simple.

Thank you. Thank you. That was just the bee's knees.
Has been implemented and works a treat as the page being refreshed is only very small (less than 500 characters) and is probably smaller than the request the browser sends every 5 seconds!

Sorry for the spelling error there and glad it helped. You can click the Not Yet Answered button if this is working for you.

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.