couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan Lehnardt (JIRA)" <>
Subject [jira] Closed: (COUCHDB-257) HTTP caching headers don't provide expected behaviour
Date Tue, 15 Sep 2009 22:43:57 GMT


Jan Lehnardt closed COUCHDB-257.

    Resolution: Won't Fix

>From dev@:

Christopher Lenz:
This is a somewhat misleading description; it's not the lack of an Expires header on CouchDB
responses that results in incorrect caching, it's a (really ugly) bug in the XMLHttpRequest
implementation of IE6 that does this. As far as I know, the cache control headers sent by
CouchDB are absolutely correct according to the HTTP specification. Unconditionally adding
an Expires header (with a date in the past) just to workaround the XHR bug in IE6 *completely
disables* any caching by any user agent!

Note also that IE6 gets cache invalidation right when you don't go through XMLHttpRequest
(that is, request CouchDB documents/views directly).

A CouchDB-based application that runs on the client (CouchApp-style), and that needs to work
on IE6, has the option to force all XHR requests to invalidate the cache (for example by using
jQuery's "cache=false" option to AJAX requests, which simply adds an extra timestamp-valued
query string parameter). In addition, it can choose to do so if, and only if, it detects to
be running on IE6. And of course, applications accessing CouchDB only through server-side
code do not need to care about this issue at all.

Presumably we *could* add the browser detection and the conditional addition of an Expires
header to the CouchDB HTTP server, but browser detection is a really slippery slope that I
think we should avoid, and IE6 is likely (or so I hope) to be pretty much extinct by the time
CouchDB reaches the 1.0 mark. In any case, I'm -1 on any patch that does this unconditionally,
and -0.5 on any patch that does the Expires header dance conditionally. I'd be okay with adding
the cache busting trick to Futon (but again, only conditionally), and documenting the issue
and workaround for CouchApps.

> HTTP caching headers don't provide expected behaviour
> -----------------------------------------------------
>                 Key: COUCHDB-257
>                 URL:
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 0.8.1, 0.9
>         Environment: Server: Ubuntu Hardy on x86. Client: Windows XP (32-bit).
>            Reporter: Vinay Sajip
>            Priority: Minor
>         Attachments: caching-header-patch.diff, expires.patch
> The HTTP caching headers currently put out cause IE (for example) to not display information
correctly in Futon. It's easy to reproduce: I open windows in Firefox and IE simultaneously,
do an update using Firefox (e.g. add a new document) and refresh the IE window. The updated
document count is not shown. If I clear the browser cache and try again, the updated information
is displayed.  The HTTP header put out is
> Cache-Control: must-revalidate
> which seems to me insufficient - for IE, at least. Is there way of configuring these
headers, to for example 
> Cache-Control: no-cache
> Pragma: no-cache
> Expires: some date in the past, or the same value as the Date: header
> Christopher Lenz has said about this that "This is due to extra-aggressive (and against
the HTTP spec) caching   that IE does on XMLHTTPRequests. A patch would need to do user agent
sniffing to conditionally add the  "cache: false"  parameter to the jQuery ajax() invocations
in   jquery.couch.js (and maybe elsewhere). I wouldn't want to add this for all user agents,
as it basically circumvents any caching for AJAX  requests (even for not-craptastically-broken
implementations), and  thus would add quite a bit of unnecessary overhead."
> To this, I would comment that I don't believe a patch to the client-side code in Futon
would be sufficient. There are other clients out there, some of which will be on Windows and
so by default use the (acknowledgely broken) Microsoft stack. In my view it is more important
to err on the side of correctness than performance - so I believe the headers generated server-side
need to change, as well as perhaps Futon client-side changes.
> I note that handle_uuids_req in couch_httpd_misc_handlers.erl uses the no-cache/Expires
scheme I mention.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message