Setting cache control headers

Caching is very important. With a simple cache control header, we can save bandwidth, lower our server load, and make our application feel faster and more responsive.

Tonic has a built in support for the relevant response headers, all you need to activate them is to add a cacheControl property containing the number of seconds to cache the representation for.

mimetype: text/plain
cacheControl: 3600

Something we want cached by our clients.
resources/cachedResource.html

By default all representations are cached for 86400 seconds, to stop this, set the cacheControl to zero.

The cache control response headers that are send to the client are:

Etag: "a0dc5e09d69dafe0b0453a5fcf0dafa6"
Last-Modified: Mon, 28 Jan 2008 22:44:42 +0000
Cache-Control: max-age=3600, must-revalidate

Etag and Last-Modified are for HTTP 1.0 and 1.1 conditional GETting, and the Cache-Control header gives the number of seconds for the client to keep hold of the representation for.

Back to documentation home
Created Jan 28, 2008, last modified Jan 29, 2008