|
|
|
|
| Tutorial |
Page Caching
The session library also allows you to control how pages are cached.This is done via
the HTTP Cache-Control directives. In the PHP configuration, the cache_limiter
directive can be set to nocache, private, or public. As discussed in Chapter 6, this
is very similar to the behavior of the PHPLib (but note that the PHPLib uses just
no instead of nocache).
Page caching is set to nocache by default.This prevents caching at all, and is also the
standard behavior of all PHP pages, as you may know. For dynamically generated
pages, this is usually the preferred method, since these pages will often differ from
request to request. However, you may want to rethink this strategy for certain parts of
your application that don’t change often—your server hardware will thank you for it.
The output header will look like this:
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-cache
Pragma: no-cache
Setting cache_limiter to private will allow browsers to cache the pages, but
not proxies or other gateway applications. Note that this differs from the
proxy-revalidate directive; in the latter case, the proxy is allowed to keep the
content of the page to issue a revalidation instead of a full retrieval.The generated
HTTP headers will look similar to these:
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, max-age=10800
Last-Modified: Thu, 03 Feb 2000 15:56:11 GMT
The last possible value, public, allows full caching by both the client and proxies. Be
careful when using the public cache option: Pages generated with this setting may be
available to third-party users who have access to proxies.
When using public caching, the cache_expire PHP configuration directive will be
taken into account.This directive specifies the number of seconds after which the
cache will expire.The generated headers could look like this:
Expires: Thu, 03 Feb 2000 18:56:11 GMT
Cache-Control: public, max-age=10800
Last-Modified: Thu, 03 Feb 2000 15:56:11 GMT
PHP 3.0 Sessions
Because the PHP 4.0 sessions API is nice and intuitive to use, we wanted to have that
for PHP 3.0, too. Having a consistent session interface for both versions would be
great, we thought—and for some small projects you just don’t want to use the
PHPLib. So we had a closer look at sessions.c and ported it over to native PHP 3.0.
While we didn’t preserve some internals, such as the algorithm used for the generation
of the session ID, we tried to make the API 100% compatible to PHP 4.0. Some limitations
obviously do exist: Automatic URL rewriting isn’t available, for example. But if
|
|
|
|
|
|
| Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist |
|