1

Full Story:

I'm backing an HTML application with expression engine, using the wonderfully unreliable appcache tech. It works in firefox and chrome, but not IE and i've nailed (using charles proxy debugger) it down to the fact that IE is refusing to cache the page because it has the above cache-control headers.

So, I need to stop that happening. Of course, there is a setting in EE:

Admin > Output & Debugging > Generate HTTP Page Headers? 

But changing that has no effect.

I have tried using meta tags for cache-control, but of course, that is no longer valid html, and it would have no effect, anyway (despite knowing this, i did try it, and it did have no effect).

I am certain it is EE causing it, since opening /index.php in the root and doing the following results in the correct headers (though, obviously, no markup).

header("Cache-Control:public");
die();

If i leave the above header line in place, the incorrect headers are being sent, conclusion being that EE is sending its own headers, after I'm sending that one, meaning it is being overwritten.

I've found declaration in EE_Output.php, but this isn't where the headers are being sent for templates.

So, I need to find where they are being sent... and I can't seem to find anywhere obvious - which is obviously irritating.

If you guys can offer any assistance, that'd be really useful.

  • I don't think that in this case EE do something at all. It is default headers of your server app (apache/nginx?) and ee just don't overwrite it for regular pages. Try to create an php file (outside of ee) with phpinfo(); for example. – Max Lazar Feb 6 '14 at 10:26
  • Have already proved that these headers are not server default by doing what you suggested. The overriding is definately coming from somewhere in ee... have fixed it with a hack, which ill post as an answer. – stevesweets Feb 6 '14 at 13:50
  • Further info. Using the header set then die method proved conclusively that the headers are coming from ee or ci. I can't find where, but it definately is. This led to my conclusion below. – stevesweets Feb 7 '14 at 9:29
  • just for sure - how did you tested it? What file you used for this? – Max Lazar Feb 7 '14 at 9:32
  • index.php, system\codeigniter\system\core\CodeIgniter.php, system\expressionengine\controllers\ee.php (continued this path, following function trail)..... as said; i proved conclusively that the headers must have been coming from ee/ci, but did not have the time to get further into finding precisely where. – stevesweets Feb 7 '14 at 13:40
2

I was able to drill through the ee code and find a place where I can overwrite the headers.

If you need to do the same... open this file:

ee_system_folder/codeigniter/system/core/Output.php

Look for this function:

function _display($output = ''){

Look for this code:

// Does the controller contain a function named _output()?
// If so send the output there.  Otherwise, echo it.
if (method_exists($CI, '_output'))
{
    $CI->_output($output);
}
else
{
    echo $output;  // Send it to the browser!
}

Immediately before that code, i added my own header in (in this case a public header).

header("Cache-Control: public");

// Does the controller contain a function named _output()?
// If so send the output there.  Otherwise, echo it.
if (method_exists($C....

This successfully overrides wherever the headers are coming from, so it works even if its not ideal.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.