views:

306

answers:

1

The Yahoo User Interface library offers rollup support if you use their CDN. I'm using Zend Framework 1.8.0 and was wondering whats he best way to go about replicating this so as all our css or javascript files can be rolledup into one tag - thus one http request.

I am using the standard MVC components with a .htaccess file that rewrites everything through index.php unless the file or folder physicaly exists or is mapped on the server.

I'd like to have the final rollup file cached client side (if the client supports it) for efficency and further reduced http requests.

+1  A: 

Hopefully I've understood your question correctly.

There are a couple of jobs here - one is to concatenate the content of several files in request variables into one response and then the other is the management of the caching process.

The first should be fairly simple, taking a list of paths and adding the contents to the file in memory, and the second can be managed easily with this great helper which allows you to easily set modified/expires headers to allow client side caching

David Caunt
I agree about rolling up the file in memory. The Noginn XSendfile helper you recommend looks like it will do the job, however it requires a module to be added to Apache or Lighttp. Ideally I need an in PHP Code solution, as the underlying server is something I may have limited influence/controll over.
Dominic Webb
To clarify - that helper doesn't require sendfile (and could be named better) but is a great way to handle file downloads. On reflection it'd be better performance-wise to construct the file in memory, and cache on disk for subsequent requests.
David Caunt
Okay - so to clarify at my end, The Noginn helper is a totaly in code solution? Thanks for this help, in advance
Dominic Webb
Yep - easy way to push data from memory or files from disk to the browser, just using basic PHP :)
David Caunt