CodeIgniter Forums

Full Version: Proxy Cache Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I developed site that need user authentication.
When I access from local network server everything running well.
In the right site page, it show login form if user not logged in, and show user information when they logged in.
But when I access from internet some page was cached by ISP proxy.
After logged in right site page still show login form, after reloading by press F5 key user information showed.

I used
$config['url_suffix'] = ".html";
in my config

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="0">
in every page

But it doesn't solve my problem.

I read in PHP manual
Quote:PHP scripts often generate dynamic content that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with:
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

Where should I put that script?

I try put the script on hooks:
$config['enable_hooks'] = TRUE;
$hook['pre_controller'][] = array(
  'class'    => 'nocache',
  'function' => 'pre_controller',
  'filename' => 'nocache.php',
  'filepath' => 'hooks',
  'params'   => array()
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class nocache {

  function nocache()

  function pre_controller()
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past


Every page doesn't cached by ISP proxy, and it running well now.
I'm not sure about that, is there somebody can explain me please?