HTTP Refresh Header (Meta Refresh)

There’s an HTTP Refresh header that can be used to “refresh” a page every N seconds.

Refresh: 5

When the header above is sent to a client (browsers) that supports it, the page will be refreshed every 5 seconds. The Refresh header is actually non-standard (not part of the HTTP standard).

This header is part of a feature that was introduced by Netscape Navigator back in the 90s called “Meta refresh” that is still supported by some modern browsers. This method was introduced for redirections and refreshes in two ways:

  1. Using a meta tag.
  2. Using an HTTP header.

Using a meta tag, this is what you’d need to do:

<meta http-equiv="refresh" content="5; url=https://example.com/">

The meta tag will load the url specified (example.com) after 5 seconds. If the url is not specified, then the page will be refreshed or reloaded (same URL) after 5 seconds. Hence with the url specified, redirection can be achieved, where as without it refresh will be achieved.

The HTTP header equivalent that a server can send is this:

Refresh: 5; url=http://www.example.com/

If the url is specified, then that’ll be loaded after 5 seconds. Otherwise as we saw above, without the url the page will be refreshed after 5 seconds.

Meta refresh is an old way, discouraged and should not be used. Some server-side tools still use this technique to do a quick refresh or redirect the client.

Leave a Reply

Your email address will not be published.