EllisLab text mark
Advanced Search
     
Compressed Asset Provider
Posted: 20 November 2007 07:28 PM   [ Ignore ]
Joined: 2007-10-25
203 posts

Hello all. Been playing around with something. Unfortunately, I, like many people, do not have ZLIB on my production PHP install, but I need a way to provide gzip’d assets (css, js, jpg, jpeg, gif, png, bmp).

Therefore, I present Combust (codename, we’ll see if I stick with it), a compressed asset provider.

Advantages:
- caching of gzipped files
- ZLIB not required on your production system, gzip-cache the file locally, then copy to your server.
- if no ZLIB, content will be servered as normal

*Just a note: This is a rought sort of ‘alpha’ version. Feel free to make suggestions or contribute.*

Usage:
Load the AssetProvider library.

set_directory( <directory> ) - sets the working base directory. Automatically set to APPPATH. Cannot be set outside of server root.

send_file( <path/to/filename>,<enable caching T/F> ) - will not accept a path outside of the current working directory for safety—preventing user submission of “../../../file/outside/server”. Second parameter determines whether file should be cached.

library/AssetProvider.php on privatepaste

*One last note: Really, this is rough code. I’ll be refining it over the coming weeks and will continue to update it if there is interest.*

 
Posted: 20 November 2007 09:34 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-10-25
203 posts

Next update (tomorrow):
- disallow filetypes such as php, inc, etc
- anything else I think of tonight

 
Posted: 20 November 2007 11:03 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-23
3194 posts

Looks nice, and can’t wait to see where you go with this.  I’m moving this post into “ingited code” to give it the attention it deserves.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design