I've just updated my recent GzOutput.class.php (more recent than last file published on Ajaxian :D) and tested successful on many browsers.
The difference from other cache-manager files, functions or classes is that GzOutput is totally indipendent from folders or page type, You could use them to increase JSON responses (using text/plain as Content-Type) as well as XML, (X)HTML, CSS or every kind of document You need.
You could combine this class with a JavaScript compressor (to improve download speed) and you don't need to care about output changes because ETag is based on sha1 and not on every mktime of each file (it means better server performances).
The only think that You need to remember is that You don't need to write everything before to use this class (empty spaces, some char or pages can't be write before its usage).
Four public methods are really simple to use:
create, sending an output string and a Content-Type type to use cache if it's available (if not, forces next download to use cache)
createNew, sending an output and a Content-Type to force everytime the download (it's a must for Ajax interactions with XML, JSON or serialized strings)
createFromList, sending an array of files and a Content-Type to create a single generic output file including each file content and using create properties for output
createNewFromList, sending an array of files and a Content-Type to create a single generic output file including each file content and using createNew properties for output
That's all, do You like it ? :-)
No comments:
Post a Comment