Setting output cache looses HTTP-header content-type override |
[eluser]alphabase[/eluser]
Hi, I need to set my content-type through the output class, since my HTTP server does not do this automatically and GTmetrix requires this for speed optimalisation. So I've added this just before loading my views: Code: $this->output->set_header('Content-Type: text/html; charset=UTF-8'); That seems reasonable, and actually also works fluently. Now I also wish to use the output caching, so I've added also before loading my views: Code: $this->output->cache(3600); But this seems to override my HTTP-header overrides, giving me the response header: Quote:Content-Type:text/html Instead of: Quote:Content-Type:text/html; charset=UTF-8 I've also tried adding the set_header to my controller's construct function, but this does not work. Any idea how to fix this?
[eluser]Aken[/eluser]
Headers are not retained in cached files generated by the Output class in CI 2.1.3 and below. It has been added in 3.0. You can see how I did it here: https://github.com/EllisLab/CodeIgniter/pull/2151 Should be fairly easy to extend the Output class as a temporary solution for you. |
Welcome Guest, Not a member yet? Register Sign In |