Skip to end of metadata
Go to start of metadata

Zend Framework: Zend_Cache_Backend_Compression Component Proposal

Proposed Component Name Zend_Cache_Backend_Compression
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Cache_Backend_Compression
Proposers Maxime Varinard
Zend Liaison TBD
Revision 1.0 - 23 Juil 2009: Initial Draft. (wiki revision: 9)

Table of Contents

1. Overview

Zend_Cache_Backend_Compression will add some compress features to "Output" Zend_Cache. This tool will help to compress and obfuscate javascript output dynamically generated.
Next features can be to compress html and css.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will purpose different compress tools (Jsmin, Yui and Dean Edwards JavaScript's Packer). Their job is to compress and obfuscate. This component won't compress and obfuscate because some opensource and very good tools already exist.
  • This component will use a file to store data.
  • This component will manage an output only.

4. Dependencies on Other Framework Components

  • Zend_Cache
  • External javascript compressor library : Jsmin, Yui and Dean Edwards JavaScript's Packer (putted into asset dir)

5. Theory of Operation

The component is instantiated when you'll call a Zend_Cache_Backend.

6. Milestones / Tasks

Describe some intermediate state of this component in terms of design notes, additional material added to this page, and / code. Note any significant dependencies here, such as, "Milestone #3 can not be completed until feature Foo has been added to ZF component XYZ." Milestones will be required for acceptance of future proposals. They are not hard, and many times you will only need to think of the first three below.

If a milestone is already done, begin the description with "[DONE]", like this:

  • Milestone #: [DONE] Unit tests ...

7. Class Index

  • Zend_Cache_Compression
  • Zend_Cache_Backend_Compressor_Default
  • Zend_Cache_Backend_Compressor_Interface
  • Zend_Cache_Backend_Compressor_Jsmin
  • Zend_Cache_Backend_Compressor_Yui

8. Use Cases

UC-01

This is create cache

UC-02

This is the way to compress CSS

UC-03

This is the way to compress javascript

9. Class Skeletons

Labels:
zend_cache zend_cache Delete
cache cache Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jul 28, 2009

    This proposal needs a lot more information:

    • What are the different compression backends proposed, how do they work, and for what types of files?
    • What other possible compression backends do you envision in the future? Why were those in the proposal selected specifically for this iteration?
    • Your proposal mentions "obfuscation", but I don't see any such functionality in the use case or code skeletons
    • Need more use cases, and they need much more detail – include some narrative behind each use case, indicating what the need is, and how the new functionality accomplishes it.

    I'm returning this proposal to "New" status. Please get community review prior to requesting recommendation again; I know there are a number of community members who may have opinions on the design and functionality.

  2. Aug 20, 2009

    I completed this proposal. Code is ready for community alpha testing.
    I'm waiting your feedback.

  3. Aug 20, 2009

    Maxime: the process is quite clear: you need to ask for community review first, and then mark it as ready for recommendation. I've moved it back to "Ready for Review", which is the area for community review. Please post an email to fw-general and/or zf-contributors asking for feedback on the proposal before you mark it as ready for recommendation again.

    I have some feedback as well. First, thank you for updating the use cases and code skeletons. However, I still have questions:

    • Why is the usage different than other cache adapters? Typically, you attempt to load() from the cache, and then, if it returns boolean false, generate and cache the contents. Your use cases show something quite different.
    • Is this intended for inline JS/CSS within your templates, or for caching content for static JS/CSS files? My experience with JS/CSS compressors has been that you usually generate static files within the docroot, but this isn't clear from your use cases or your description of the component.
    • From the use cases, it appears you're using output buffering to perform the caching. In most cases, it seems like it would be as easy or easier to simply generate data and save it without the need for ob() functions. Can you indicate why ob is necessary?
    • Can you better describe the intended use cases of the component as a narrative in the Overview and/or Theory of Operation sections, please?
  4. Aug 21, 2009

    It's better to have a component that do js/css compression, and optionaly use Zend_Cache to optimum performance, like Zend_Db_Table store a table description in Zend_Cache, but we don't have Zend_Cache_Db_Table to do this.

    Other thing that we don't need to know internal storage of Zend_Cache backends, and you are proposing to use a Zend_Cache struture do to a compression, store a data and to retrieve a diferent data (compressed or minified), I think that cache it's to store and retrieve the same data.

    On the other hand, a Zend_Cache_Compression to store some big data to save disk space it's more acceptable, but the compression will slow don't the application.

    Integration with Zend_View to automatic join / compress / minifie js and css files are welcome, but it's a hard job to do this, specialy with css.

  5. Aug 22, 2009

    In my understanding a Cache backend is used internally to store in a wished data structure.
    What ever I enter within a cache, I will get the same data when I retrieve it.

    It is not intended to get files which can be used external like JS or related.
    When I want to compress JS files I would use Zend_Compress / Zend_Filter_Compress / Zend_View or related.

    -1 from my side... Zend_Cache is the wrong place for such a feature. I would understand when you want to compress/decompress Cache files but this would only apply to a very small amount of Backends as all binary backends (APC, Memcached) are already compressed.

  6. Aug 26, 2009

    Thanks for your feedback.
    You've right, Zend_Compress should be better. I'll update this wiki page and rename Zend_Cache_Backend_Compress to Zend_Compress.

  7. Aug 26, 2009

    Thanks for your feedback.
    You've right, Zend_Compress should be better. I'll update this wiki page and rename Zend_Cache_Backend_Compress to Zend_Compress.

    I'll ask to Steven Brown to help him here : http://framework.zend.com/wiki/display/ZFPROP/Zend_Compress+Proposal+-+Steven+Brown

  8. Jul 22, 2010

    I have a fully working set of filter components that perform minification on css, javascript, and html. You can see them under the 'ready for review' section of the wiki. I think this proposal would best serve the framework by being refactored as a view helper component that can optionally use existing cache backends for storing the processed output. We should strive to keep caching and minification separate as appropriate to promote the quality and reusability of the zend framework.

    1. Jul 22, 2010

      Great stuff I'll check your proposal.

  9. Feb 08, 2011

    Archiving this proposal, feel free to recover it when you want to work on it again. For more details see this email.