views:

206

answers:

1

Hello all,

I'm having a quite annoying problem, and came up with a quite ugly hack to make it work.

I develop an Hta application using a CouchDB database (for internal company use). The problem is there seems to be some very aggressive caching of the database queries, and it's been hard to come up with solutions. So the updated data in the database just won't come up in the browser, who still has the previous request results in his cache, until the entire app is started anew.

Oh, and CouchDB (or it's mochiweb server) doesn't allow unknown GET variables, so the usual solution of appending some sort of timestamp just won't work.

I have found some sort of solution, but it's damn ugly. Solutions are:

  • Only open documents with latest revision number (easy and nice, won't work on views)
  • Use apache as forward proxy listening to 200+ ports, and select one at random on each read query. (that's the ugly one).

Hta accepts ajax calls to other ports (maybe even on other domains, strange behaviour), so it works nicely, I just have a 1/200 chance that new data won't come up, but that's still better then 1/1, I can live with that.

So what I'm asking is, is there a better solution to this ? Can I hack in to the mochiweb server to modify cache headers (and hope they're not going to be ignored) ? Is there a special unknown "throwaway" key I could use in the url's to append some random string ? Or is there a way to tell Hta not to cache anything (from within the app, this is supposed to work on hundreds of computers) ?

+2  A: 

it's still ugly but slightly less ugly than your current apache setup but Can't you use an apache rewrite rule to allow you to set an arbitrary no_cache attribute on the url? apache can throw it away so couchdb won't see it.

Jeremy Wall
Ooh, great idea, I'll try it out, see if I can make it work.
Berzemus
I did not really enjoyed tinkering with rewrite conditions and rules, but alas, it works, nicely. Thanks a lot.
Berzemus
you might also consider using something lighter than apache if all you need the apache server for is a proxy. nginx is pretty light and should do what you want.
Jeremy Wall