PermaLink Domino web server: Client side caching of images
(I know. Not Thursday.)

This tip is particularly applicable to blogs hosted on Domino, most especially where the same image (*.jpg, *.gif etc) is often used on many different pages, for instance in a header block.

It should also be useful in any web site where static images form part of the design.

Try this.
  1. Get a copy of Sam Spade for Windows (what do you mean, you don't already have it?).

  2. Locate an image on your Domino web site, right click and copy the image location to the clipboard.

  3. Paste it into Sam Spade (just give the Sam Spade application focus and Ctrl-V will do it).

  4. Click the "Web" button (this is the famous Sam Spade safe browser). Then click OK.

You should see something like this:

HTTP/1.1 200 OK
Server: Lotus-Domino
Date: Tue, 11 Jul 2006 06:17:26 GMT
Connection: close
Last-Modified: Tue, 11 Jul 2006 06:17:20 GMT
Content-Type: image/gif
Content-Length: 1400
Accept-Ranges: bytes
Content-Language: en
Cache-control: private
ETag: W/"MTAtODA4RC04MDI1NzFBODAwM0JGRUVDLTgwMjU3MUE4MDA0OEZGMkItMA=="

The salient features of this (for the purposes of client side caching) are:

  1. No Expires header
  2. Cache-control: private

This means that this and every similar resource on your Domino site is never cached client side and is served up fresh every time a page is loaded. For a site which uses images as part of the furniture of every page, this is very inefficient.

Cue Domino Web Site Rules.

In the Domino Directory, open the web site document for the web site in question. Click Web Site/Create Rule... and fill it in like so:

cachegifimagesdomino.gif

You could repeat this for other types of image resource.

Stop and restart the HTTP server task, then use the Sam Spade safe browser to retrieve an image again. You should see something like:

HTTP/1.1 200 OK
Server: Lotus-Domino
Date: Tue, 11 Jul 2006 06:29:10 GMT
Connection: close
Last-Modified: Tue, 11 Jul 2006 06:16:42 GMT
Content-Type: image/gif
Content-Length: 1400
Accept-Ranges: bytes
Content-Language: en
ETag: W/"MTAtODA4RC04MDI1NzFBODAwM0JGRUVDLTgwMjU3MUE4MDA0OEZGMkItMA=="
Expires: Fri, 21 Jul 2006 23:59:59 GMT
Cache-control: public

That image and any others that match the criteria in the HTTP headers rule will now be cached by web browser clients for a little over 10 days (till midnight on the day 10 days from now) and will not be reloaded every time a user views a page containing it, saving him/her time and you bandwidth.

You're welcome.

Category: SnTT
Technorati:

Comments :

1. Frode11/07/2006 20:39:52


The "Live HTTP Headers" extension for Firefox is allso usefull for viewing both client and server headers: http://livehttpheaders.mozdev.org/index.html




2. Ben Rose12/07/2006 10:41:03
Homepage: http://www.jaffacake.net


Thanks Chris, was very interesting setting all that up yesterday.




3. Simon Boulton12/07/2006 11:44:11


Thanks for sharing that, Chris. One of the best tips I've seen for a long time!




4. Christian Brandlehner27/07/2006 07:09:00
Homepage: http://chris.brandlehner.at


You can do even more than just *.gif ->
http://chris.brandlehner.at/Brandlehner/cab_blog.nsf/d6plinks/CBRR-69WKNV




5. Wright Furman16/08/2006 22:31:10
Homepage: http://www.dennys.com


I have been attempting to do this same thing on my development server, but the images (jpg and gif) that are stored as attachements in documents or as image resources in the database never receive an expires tag when I use IBMs Page Detailer to show the headers. I am using the same settings but it is not working - could I be having trouble with my web site document not loading properly? I am using Domino 6.5.5 FP1. How do you know that your Web Site document has been loaded properly?




6. Chris Linfoot17/08/2006 09:19:32


This isn't a problem with the web site doc. Check the image tags. The above instructions assume image tags like so:

<img src="path/filename.gif">

When you use an image resource, it will have a tag somewhat like this:

<img src="/app.nsf/.../$Body/0.12A6?OpenElement&FieldElemFormat=gif">

As you will see, the latter does not match the wildcard *.gif*. It does match *gif*, so you could try that.

But if you are using image resources in a Domino application, the more elegant solution would be to code HTTP response header behaviour into the application itself and not rely on a web site rule to fix it for you.




7. Sanjay Sinha25/11/2007 20:57:40


Thank you very much for this post. In the last few days, I have found out more about HTTP 1.1 protocol than I really want to know. This post would have saved me a couple of days.
I was wondering if anyone knows how to give the expiry settings for .js and .gif at the application level? (I don't have access to the server settings).





8. Phil Hulme07/02/2008 15:51:46


Excellent. I've been half-looking for the answer to this for 3 or 4 years!




Unable to post a comment? Please read this for a possible explanation...
Add Manual Trackback
Please enter the details of the trackback post. Your trackback will not appear on the site until it has been verified. This won't be immediate, as trackbacks are validated on a scheduled basis. Be patient.











Search
Popular Categories
Monthly Archive
Other stuff
ClustrMaps
Contact Me
Meta
Proudly powered by IBM Lotus Domino 8 Proudly powered by IBM Lotus Domino 8

Subscribe to articles Subscribe to articles feed

Subscribe to comments Subscribe to comments feed

ROR info ROR info


My Amazon wish list Wishlist


Wikio - Top Blogs - Technology
Like what I do?
Research Autism Then please consider a donation to support the work of Research Autism.
Idea Jam
Planet Lotus
Dilbert