An Idea on Browser Cache

0
Your rating: None

Web browsers and proxy servers (something ISPs and other corporations create to improve network efficiency) habitually cache Web pages. Caching a page is a matter of storing its content (or part of its content, like an image or video) and then providing that stored version, rather than the version on
the server, when a request is made.

For most end users, this is not a problem. In fact, they may not be aware that they are receiving an outdated version of a page or image. But if, while developing a site, you’ve struggled to get your Web browser (let’s face
it: the likely culprit is Internet Explorer) to recognize changes you know you’ve made in a page, then you’ve seen the dark side of caching. With your dynamic, PHP-driven sites, sometimes you want to make certain that end users are getting the most up-todate version of your pages.

Caching—both in Web browsers and proxy servers—can be affected using PHP’s header() function. There are four header types involved:
◆ Last-Modified
◆ Expires
◆ Pragma
◆ Cache-Control
The first three header types are part of the HTTP 1.0 standard. The Last-Modified header uses a UTC (Universal Time Coordinated) date-time value. If a caching system sees that the Last-Modified value is more recent
than the date on the cached version of the page, it knows to use the new version from the server.

Expires is used as an indicator as to when a cached version of the page should no longer be used (in Greenwich Mean Time). Setting an Expires value in the past should always force the page from the server to be used:
header (“Expires: Mon, 26 Jul 1997 05:00:00 GMT”);

Pragma is just a declaration for how the page data should be handled. To avoid
caching of a page, use:

header (“Pragma: no-cache”);

The Cache-Control header was added in HTTP 1.1 and is a more finely tuned option. (You should still use the HTTP 1.0 headers as well.)

Putting all this information together, to keep all systems from caching a page, you would use these headers:
header (“Last-Modified: Thu, 9 Nov 2006 14:26:00 GMT”); // Right now!

header (“Expires: Mon, 26 Jul 1997 05:00:00 GMT”); // Way back when!
header (“Pragma: no-cache”);
header (“Cache-Control: no-cache”);

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

SEO Architect,SEO Specialist reflect my values.

By enduring black hat methods the SEO industry is setting itself up for washout and sleepwalking into oblivion.

Jobs in India