Thursday, August 5, 2010

Browser Cache Control



META-tags are used to provide special information to browsers and search engines regarding the handling or content of your pages.

Browser Cache Control

Many of today's browsers cache (or hold onto) pages that have been previously viewed/visited.  This is done to optimize the amount of time it takes to return to the page.  Sometimes a page author wants to prevent their page from being cached because the contained information is time sensitive.


<!--
The "expires" "http-equiv" meta-tag can be used to control
the cacheing of pages with Netscape 3.0 and later browsers.
The 'content="0"' form tells the browser to not cache the
page at all.
-->

<meta http-equiv="expires" content="0">
<meta http-equiv="expires" content="Tue, 14 Mar 2000 12:45:26 GMT">
<!--
The "pragma no-cache" http-equiv meta-tag was introduced
in the HTTP/1.1 specification. Not all browsers or proxy
agents may support these operations. To be safe you may
want to specify both expires and pragma in the file.
-->

<meta http-equiv="pragma" content="no-cache">

<!--
The "Cache-Control" http-equiv meta-tag was introduced in
the HTTP/1.1 specification. The allowed "content" values
include:
* public - may be cached in public shared caches
* private - may only be cached in private (client) cache
* no-cache - may not be cached
* no-store - may be cached but no archived

Cache-Control modifiers include:
* no-transform - proxy servers are not allowed to transform
the cached data.
* must-revalidate - proxy servers and other caching mechanisms
must revalidate the original file each time the file is
accessed.
* proxy-revalidate - same as must-revalidate, but it only
applies to proxy servers.
* max-age=<seconds> - client/browser is willing to accept
a page that is more recent than the number of seconds
indicated.
* s-maxage=<seconds> - same as max-age but applies to shared
proxy servers and other shared caching mechanisms.

The directive CACHE-CONTROL:NO-CACHE indicates cached
information should not be used and instead requests should
be forwarded to the origin server. This directive has the
same semantics as the PRAGMA:NO-CACHE.

Clients/Browsers SHOULD include both "pragma no-cache" and
"cache-control no-cache" http-equiv meta-tags when used with
a server not known to be HTTP/1.1 compliant.
-->

<meta http-equiv="cache-control" content="no-cache, must-revalidate">

<!--
Be aware that some search engines will remove pages from
their indexes based on the "expires" meta-tag. This
implies that pages that identify a 'content="0"' form may
not be indexed at all.
-->

Ownership

These meta-tags are primarily informational.


<meta name="author" content="Boo Boo Bear">
<meta name="copyright" content="copyright 2000 Bear Consulting Group">
<meta name="date" content="20 Apr 2004">

Refresh

The biggest problem with the "refresh" meta-tag method of page-refresh is that it adds to the visitor's page-history.  This means that for each automatic page refresh/reload your site visitor must select the browser's back button.  This potentially can be a considerable bother to your visitors as well as a confusion.


<head>
<!--
The "refresh" meta-tag's content identifies the number of
seconds to delay before refreshing the current document.
Notice that the URL tag is not specified, indicating that
the current document will be refreshed.
-->

<meta http-equiv="refresh" content="2">
</head>

Redirection

The biggest problem with using the "refresh" meta-tag method of page-redirection is that it adds to the visitor's page-history.  This potentially can be a considerable bother to your visitors as well as a confusion.



<head>
<!--
The "refresh" meta-tag's content identifies the number of
seconds to delay and the location (URL) to load.

When using the refresh meta-tag you should not specify "0"
for the delay time because your site's visitor will have
trouble moving "back" through their browser's history.
-->

<meta http-equiv="refresh" content="5; URL=redirectiontarget.htm">
</head>

Search Engine

There are various ways to provide hints for search engines.  There is no way to guarantee how a search engine indexes your site.  Some search engines use the "robots" meta-tag to provide hints regarding how to traverse a site's pages.  Other search engines use the robots.txt file or a combination of techniques.


<!--
The following meta-tag identifies to search engines
that this file should be indexed. This is the default
so you rarely see this usage.
-->

<meta name="robots" content="all">

<!--
The following meta-tag identifies to search engines
that this page should not be indexed nor should any
contained links be followed to other local pages.
-->

<meta name="robots" content="none">

<!--
The two following meta-tag robots have the same result,
telling the search engines to not index the current page,
but allow search engines to followed any contained links.
-->

<meta name="robots" content="noindex">
<meta name="robots" content="noindex,follow">

<!--
Lastly index the current page but don't follow local links
-->

<meta name="robots" content="index,nofollow">

Some search engines use the "keywords" and "description" meta-tags to help in the indexing of a single page.  Many engines will confirm that the listed keywords actually occur on the page.  If they don't then the page may be rejected as a spam page.


<meta name="keywords" content="meta-tags, metatags, keywords, description">
<meta name="description" content="concise description of what this file is about">

Window Target

Specifies the named window target for the document/page.  This tag is not supported by all browsers, but it can be used to prevent pages from being contained in unwanted frames.


<meta http-equiv="window-target" content="_top">

Content Rating


<meta name="rating" content="general">
<meta name="rating" content="mature">
<meta name="rating" content="restricted">
<meta name="rating" content="14 years">

HTTP-EQUIV versus NAME meta-tags

'HTTP-EQUIV' tags are the equivalent of HTTP protocol headers.  Some web-servers may actually generate HTTP headers from the HTML tags, as suggested by the HTML 3.2 specification.  You should strictly avoid inventing/creating new HTTP-EQUIV tags.  Use the 'NAME' meta-tags instead.


No comments:

Post a Comment