Welcome Guest, Not a member yet? Register   Sign In
Headers set to no cache are not honored?
#11

[eluser]dmorin[/eluser]
@slowgary Not necessarily. Using the PHP headers function adds them to the output buffer at that point whereas CI's headers function adds them to the output class, but doesn't actually output the headers until the output class sends its output at the end of execution (or at least that's my understanding).

@drewbee perhaps it's a case that since you're not using normal views, the output class doesn't think it has anything to output so it never gets called?
#12

[eluser]slowgary[/eluser]
I see. So there must be something getting added to the output class before the headers, if calling the PHP header() works but CI's header doesn't. doctype() or something?
#13

[eluser]dmorin[/eluser]
Yeah, although it's not something being added to the output class since that buffers everything until the end. Instead, something is being added to the php output buffer which is causing headers to be sent. At least, that would be the case except @drewbee says he's not getting any errors.

He probably just has to do a little debugging on the output class to see if it's getting called for the final output or if instead, because of his other templating classes, if it's not getting called at all.

I don't use the CI header function for this very reason since I see no added value...
#14

[eluser]drewbee[/eluser]
I still use normal views, however, my template library 'holds on' to them until draw() is called.

Ex.

$this->template->add_view('login');
$this->template->add_view('register');

That is doing nothing more then adding each view to an array:
$this->template->views = array('login', 'register');


Then when draw() is called,
foreach($this->template->views AS $view)
{
$this->load->view($view);
}

So I am still using all the native CI stuff... There is just simply a step in between.
#15

[eluser]dmorin[/eluser]
Interesting, not sure then why the headers wouldn't be working. If you want to troubleshoot it more, check out what headers are actually being sent and let us know.
#16

[eluser]slowgary[/eluser]
The benefit to using CI header is less echo's to the browser
#17

[eluser]dmorin[/eluser]
hum, I'm not sure that makes sense. Headers are all sent to the browser at once, so regardless of which approach you take, the connection should be exactly the same...
#18

[eluser]drewbee[/eluser]
headers with standard PHP header()
Quote:HTTP/1.x 200 OK
Date: Wed, 01 Apr 2009 17:56:02 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 FrontPage/5.0.2.2635 mod_bwlimited/1.4 mod_auth_passthrough/2.1
X-Powered-By: PHP/5.2.9
Expires: Wed, 1 Apr 2009 17:56:04 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Last-Modified: Wed, 01 Apr 2009 17:56:04 GMT
Transfer-Encoding: chunked
Content-Type: text/html
expires=Wed, 01-Apr-2009 19:56:04 GMT; path=/
Proxy-Connection: Keep-Alive

And with CI's header function

Quote:HTTP/1.x 200 OK
Date: Wed, 01 Apr 2009 18:01:36 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 FrontPage/5.0.2.2635 mod_bwlimited/1.4 mod_auth_passthrough/2.1
X-Powered-By: PHP/5.2.9
Transfer-Encoding: chunked
Content-Type: text/html
expires=Wed, 01-Apr-2009 20:01:36 GMT; path=/
Proxy-Connection: Keep-Alive

So this confirms my headers are not being set.

I just dug into the base Codeigniter.php file, and for some reason, call_user_func_array() cleans out the output class var. ????

Line 230-233
Code:
echo print_r($OUT);
        // Call the requested method.
        // Any URI segments present (besides the class/function) will be passed to the method for convenience
        call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
Outputs:
Code:
CI_Output Object ( [final_output] => [cache_expiration] => 0 [headers] => Array ( [0] => Array ( [0] => Last-Modified: Wed, 1 Apr 2009 18:16:28 GMT [1] => 1 ) [1] => Array ( [0] => Expires: Wed, 1 Apr 2009 18:16:28 GMT [1] => 1 ) [2] => Array ( [0] => Cache-Control: no-store, no-cache, must-revalidate [1] => 1 ) [3] => Array ( [0] => Cache-Control: post-check=0, pre-check=0 [1] => ) [4] => Array ( [0] => Pragma: no-cache [1] => 1 ) ) [enable_profiler] => ) 1

But the following (moved print_r below the function call):
Code:
// Call the requested method.
        // Any URI segments present (besides the class/function) will be passed to the method for convenience
        call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
                echo print_r($OUT);

Outputs : [empty string] The var is defined, as it doesn't throw any errors; Which makes me think $OUT->_display() doesn't get called. Yet none of my crap would show up if this was not true.

I am officially bewildered to no end.

My template draw() method...

Code:
function draw($data = null)
    {
        $data = array('data'         => $data,
                      'page'         => $this->page);
        $this->CI->load->view('global_template', $data);
    }

The only thing different I see going on here, is that the global template.php file is the one that calls $this->load->view() for all pages within itself. As a test, I simply loaded a base view from draw(). Same effect. I'm not missing some function call that I need to for final rendering of the output class am i? Using $this->CI->output->get_output(); from my template class I ended up with everything doubled.

WTF? lol.
#19

[eluser]drewbee[/eluser]
I just stumbled upon something very interesting. It turns out my headers are being set by this function EXCEPT when accessing the default controller / method. I was always testing on the default controller / method, hence why I thought they were never being set.

Can someone please verify this for me?

To do:
1. Set a noticeable header with CI's $this->output->header() function.
2. Access yoursite.com (forcing it to use default controller/method)
- Is the header present?
3. Access yoursite.com/defaultcontroller/defaultmethod.html
- Is the header present?

For me 2 = no, and 3 = yes.
#20

[eluser]dmorin[/eluser]
The call_user_func_array() calls the initial controller method. Where are you setting the headers before the controller method is called?




Theme © iAndrew 2016 - Forum software by © MyBB