Zend Framework

Zend_Cache should remember HTTP headers (Content-Type) when using Zend_Cache_Frontend_Page

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.0, 1.0.1, 1.0.2, 1.0.3
  • Fix Version/s: 1.5.0
  • Component/s: Zend_Cache
  • Labels:
    None
  • Fix Version Priority:
    Nice to Have

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).

Activity

Hide
Fabien MARTY added a comment -

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);

Show
Fabien MARTY added a comment - 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);

Hide
Daniel Skinner added a comment -

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.

Show
Daniel Skinner added a comment - 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.
Hide
Fabien MARTY added a comment -

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

Show
Fabien MARTY added a comment - 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
Hide
Daniel Skinner added a comment -

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!

Show
Daniel Skinner added a comment - 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!
Hide
Geoff Speicher added a comment -

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.

Show
Geoff Speicher added a comment - 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.
Hide
Wil Sinclair added a comment -

Can I close this bug? Have all issues been resolved? It's not entirely clear from the comments.

Show
Wil Sinclair added a comment - Can I close this bug? Have all issues been resolved? It's not entirely clear from the comments.
Hide
Geoff Speicher added a comment -

fine by me

Show
Geoff Speicher added a comment - fine by me
Hide
Fabien MARTY added a comment -

Yes Wil, you can close it

Show
Fabien MARTY added a comment - Yes Wil, you can close it

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: