Zend Page Cache not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joshmaker
Forum Commoner
Posts: 25
Joined: Mon May 15, 2006 2:53 pm
Location: Arlington VA

Zend Page Cache not working

Post by joshmaker »

I'm confused about the results that I am getting with Zend Page Cache. It appears that the cache is not used when I load the page in FireFox or another webbrowser, but that it is used when I test the page on the command line with Apache Bench. Here is the code that I am using:

Code: Select all

<?php
include 'Zend/Cache.php';
 
$frontendOptions = array(
    'lifetime' => 7200,
    'automatic_serialization' => false,
    'default_options' => array(
        'cache' => true
    )
);
$backendOptions = array(
    'cache_dir' => './tmp/'
);
 
$cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
 
$cache->start();
 
echo time();

Now, my understanding is that when I load this script in my browser it should save the page contents (the current timestamp) and then output that initial timestamp for the next 7200 seconds. However, when I load this sample page in FireFox or Safari, it displays a new timestamp each time and nothing is saved in the ./tmp/ directory. However, when I run apache bench like this:

Code: Select all

ab -n 1000 -c 100 http://wire.dev/cachetest.php
Zend Cache files suddenly appear in the ./tmp/ directory, and speed tests seem to confirm that ab is using the cached version. Even after this file is saved by runing ab, the browser still seems to avoided loading the cached version.

Can someone help me figure out what is going on?
Post Reply