Some cache fixes

This commit is contained in:
Deon George 2011-05-29 19:33:32 +10:00
parent fe549c1c05
commit d3b97ae485
4 changed files with 10 additions and 6 deletions

View File

@ -82,7 +82,8 @@ if (isset($_SERVER['KOHANA_ENV']))
Kohana::init(array( Kohana::init(array(
'base_url' => '/pta', 'base_url' => '/pta',
'index_file' => '', 'index_file' => '',
'caching' => TRUE, 'caching' => TRUE,
'cache_dir' => '/dev/shm/lnapp',
)); ));
/** /**

View File

@ -193,6 +193,9 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
} }
parent::after(); parent::after();
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
} }
/** /**
@ -240,9 +243,6 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
* @return void * @return void
*/ */
final public function action_media() { final public function action_media() {
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
// Get the file path from the request // Get the file path from the request
$file = $this->request->param('file'); $file = $this->request->param('file');
@ -272,6 +272,9 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
$this->response->status(404); $this->response->status(404);
} }
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
// Set the proper headers to allow caching // Set the proper headers to allow caching
$this->response->headers('Content-Type',File::mime_by_ext($ext)); $this->response->headers('Content-Type',File::mime_by_ext($ext));
$this->response->headers('Content-Length',(string)$this->response->content_length()); $this->response->headers('Content-Length',(string)$this->response->content_length());

View File

@ -18,7 +18,7 @@ class Controller_NODE extends Controller_TemplateDefault {
$no = ORM::factory('node'); $no = ORM::factory('node');
$output = ''; $output = '';
$output .= sprintf(_('This server has <b>%s</b> defined nodes.'),$no->count_all()); $output .= sprintf(_('This server has <b>%s</b> defined nodes.'),$no->cached(0)->count_all());
$output .= '<br/>'; $output .= '<br/>';
$output .= '<br/>'; $output .= '<br/>';

View File

@ -16,7 +16,7 @@ return array
'file' => array 'file' => array
( (
'driver' => 'file', 'driver' => 'file',
'cache_dir' => '/dev/shm/lnapp', 'cache_dir' => Kohana::$cache_dir ? Kohana::$cache_dir : '/dev/shm/lnapp',
'default_expire' => 3600, 'default_expire' => 3600,
) )
); );