Home: Online Courses: Web Development: How to Use Meta Tags: Refreshing Pages

Using META Tags to Refresh Pages

Prev Page / Next Page

If your website is continually changing and you need the freshest most updated version to appear in your user's browser, you can use META tags to disable caching of your page. This is used often by news and other websites to keep the page reloading each time you open their page.

There are several ways to have the browser reload the page each time the user requests it. The first way is to set the page to expired. An example of this is:

<META HTTP-EQUIV="expires" CONTENT="Wed, 03 Nov 1999 12:21:14 GMT">

You can also set a future expiration date, after that time, the page will be reloaded by the web browser each time it is requested.

Another useful attribute to prevent caching in Netscape is by using "pragma":

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

Microsoft Internet Explorer often ignores META tags, versions from 4.01 and down will still cache the page occasionally, but Netscape Navigator will honor the Pragma attribute.

Another useful - and sometimes dangerous - attribute is the Refresh attribute. This tag can refresh the present page, or can refresh to a different page measured in seconds. Two examples are:

<META HTTP-EQUIV="Refresh" CONTENT="1200">

<META HTTP-EQUIV="Refresh" CONTENT="10;URL=http://www.newsite.com">

The first example refreshes the current page in 1200 seconds, or 20 minutes. The second example refreshes the page in 10 seconds, but refreshes it by loading the second URL. This can be useful if you change your site from http://www.hostingprovider.com/~myname/reallygood/index.html to http://www.mywebsite.com. You can set the original page to display a message showing your move, then 10 seconds later refresh to the new page.

Be cautious when using these two examples. Some advertising sponsors won't allow you to use a Refresh attribute since it artificially inflates your page views. Also, some search engines won't index a page with a short refresh page that directs to a different page.

Next Page: You want a cookie?