Search

What the Quote?

"(speaking on behalf of Ben Folds) I owe my existence to the profits of tobacco and the unidirectional arrow of time."

Laura Tripcony

"Elvis's belt is the shiniest thing on 'im."

Laura Tripcony

"Oh yeah. I forgot about Busta."

Laura Tripcony

« Skinning XIDED | Main| GUEST BLOG: Getting Serious about Domino as an App Dev Platform »

Using gzip on individual files in Domino

Category show-n-tell thursday
Domino uses gzip to compress most of Domino Web Access, which enhances the performance - particularly on slower connections. By being sneaky (namely, by mucking with the design of the Domino Directory), one can enable this feature for applications as well. Unfortunately, it doesn't seem to work reliably yet, which may be why it's hidden for now. The good news is that there is a legitimate way to successfully take advantage of gzip compression for static files (i.e. file resource design elements):

  1. Download gzip.
  2. Compress your file(s) using the default settings, which will shrink the content and append a .gz extension. NOTE: make a backup of each file prior to compression, as the default settings cause the file to be replaced with the compressed version, instead of a new file being created.
  3. Copy each compressed file to the appropriate location (i.e. import / refresh a file resource, store the file in Domino's html folder, etc.), and update any references to the old filename to link to the new filename.
  4. Create a website rule document in the Domino Directory:


With the rule in place, any file with a .gz extension requested from the site to which it applies will automatically receive a Content-Encoding header with a value of "gzip", which tells the browser to decompress the file prior to rendering it. For further performance benefits, the rule can be given expiration settings to tell the browser to cache the file for a given number of days or until a specific date - in the latter case, a date in the past can be specified to force the browser to always retrieve a fresh copy, in case the file will be updated frequently.

Although this approach is not applicable to dynamically generated content, it can significantly enhance performance for static content. For example, XIDED uses a single JavaScript file that (at present) weighs in at 1.45 MB prior to minification and compression. Dean Edwards' Packer reduces this to 346 KB, and gzip further reduces it to 131 KB... 9% of the original size. Even over broadband connections, such as cable and DSL, this reduces the page load delay by several seconds; over dialup, the benefit is particularly noticeable.

Comments

Gravatar Image1 - Tim,

Thanks for sharing this! I can't wait to try this out on a reporting application that we have which generates xml files that are usually 1-2 MB each. I played with gzipping them a while back and they would always come in around 100-200K, or about 10% of the typical file size. I just never figured out how to get domino to serve up the files to the browser with the right headers, etc. Hopefully this will work.

Jack