[thelist] Tip: Cachability for dynamic websites

Peter Johansson peter at johansson.org
Fri May 24 04:19:00 CDT 2002


Hi, I think I owe some tips so here's one to start with.

<tip type="Cachability for dynamic websites" author="Peter Johansson">
When building dynamic websites, take a moment and think about if you can't
reduce the bandwith/load on your server by sending a simple
"Last-Modified"-header to the client. Often it's unnecessary to render a
fresh page if nothing has changed since the user's last visit to your
site.

Figure out what element on the page that was last updated and use that
when creating the "Last-Modified"-header.

In PHP you could use something like this:

$lastModified = gmdate("D, d M Y H:i:s \G\M\T", $timestamp);
header('Last-Modified: ' . $lastModified);
</tip>


./peter




More information about the thelist mailing list