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