How to reload page every 5 seconds?


How to reload page every 5 seconds?

I am converting one layout to html; once I make the changes in code/html/css, every time I have to hit F5. Is there any simple javascript/jQuery solution for this? I.e. after I add the script, reload the whole page every 5 seconds (or some other specific time).


Solution 1:

 <meta http-equiv="refresh" content="5; URL=">

If it has to be in the script use setTimeout like:

}, 5000);

Solution 2:

To reload the same page you don’t need the 2nd argument. You can just use:

 <meta http-equiv="refresh" content="30" />

This triggers a reload every 30 seconds.

Solution 3:

For auto reload and clear cache after 3 second you can do it easily using javascript setInterval function. Here is simple code

$(document).ready(function() {
  setInterval(function() {
  }, 3000);

function cache_clear() {
  // window.location.reload(); use this if you do not remove cache
<script src=""></script>
<p>Auto reload page and clear cache</p>

and you can also use meta for this

<meta http-equiv="Refresh" content="5">

Solution 4:

setTimeout(function () { location.reload(1); }, 5000);

But as development tools go, you are probably better off with

Solution 5:

There’s an automatic refresh-on-change tool for IE. It’s called ReloadIt, and is available at . Free.

You choose a URL that you’d like to auto-reload, and specify one or more directory paths to monitor for changes. Press F12 to start monitoring.

enter image description here

After you set it, minimize it. Then edit your content files. When you save any change, the page gets reloaded. like this:

enter image description here

Simple. easy.

Solution 6:

Answer provided by @jAndy should work but in Firefox you may face problem, window.location.reload(1); might not work, that’s my personal experience.

So i would like to suggest:

setTimeout(function() { window.location=window.location;},5000);

This is tested and works fine.