ZF-2329: Zend_Cache should remember HTTP headers (Content-Type) when using Zend_Cache_Frontend_Page
Description
Example: An XML document is output with the Content-Type header set to text/xml. Zend_Cache_Frontend_Page is used and when retrieving a cached copy, the Content-Type header is incorrectly set to text/html.
See http://xeaura.xeaura-host.co.uk/sitemap.xml for an example. The cache time is about 15 seconds. Initiall you will see the document with the correct content-type (and correctly formatted in Firefox), refreshing will give you the cached copy (wrong content-type and not formatted in Firefox).
Comments
Posted by Fabien MARTY (fab) on 2007-12-19T13:46:25.000+0000
Zend_Cache doesn't send Content-Type header.
Something like this should work, no ?
require 'Zend/Cache.php') [...] we make $cache object header("Content-Type..."); $cache->start() require_once 'Model.php' [...] [...] your work to make the XML file echo($xmlString);Posted by Daniel Skinner (skina) on 2007-12-19T14:08:46.000+0000
It's a possible solution but that wouldn't work in my case or most common cases when using Zend_Controller.
In my case the module/controller/action route will determine the Content-Type header which will be set on the Response object. Since Zend_Cache is setup in the bootstrap, it does not go through the entire route sequence to determine what the Content-Type should be.
As it stands your solution would work for a lot of cases when using Zend_Cache/Zend_Cache_Frontend_Page in a simple application. However, when using Zend_Cache/Zend_Cache_Frontend_Page with Zend_Controller you are essentially limited to produce text/html responses.
Posted by Fabien MARTY (fab) on 2008-01-30T17:24:41.000+0000
I just commited a change for this into the SVN trunk
please try it (you will have to set the backend option content_type_memorization = true) and reopen this task if problem
regards
Posted by Daniel Skinner (skina) on 2008-01-31T05:23:09.000+0000
The new Zend_Cache_Frontend_Page class definately works in my case. The Content-Type header is correctly remembered and sent along with the cached output.
The content_type_memorization is a frontend option, not a backend one.
Thanks for this fix!
Posted by Geoff Speicher (gspeicher) on 2008-05-12T11:48:24.000+0000
Problem is not limited to Content-type header; other important headers (Expires, for example) are also lost. Is there any good reason not to remember and re-use all response headers for cached pages? The patch is even simpler than the patch to add content_type_memorization. Just save the entire headers_list() array in the cache and spit them all back.
Posted by Wil Sinclair (wil) on 2008-12-17T13:49:32.000+0000
Can I close this bug? Have all issues been resolved? It's not entirely clear from the comments.
Posted by Geoff Speicher (gspeicher) on 2008-12-17T13:55:52.000+0000
fine by me
Posted by Fabien MARTY (fab) on 2008-12-17T14:02:58.000+0000
Yes Wil, you can close it