[ckan-discuss] CKAN API cache problem

William Waites william.waites at okfn.org
Mon Sep 27 19:38:41 BST 2010


On 10-09-27 19:28, Anja Jentzsch wrote:
>
> when using the API to PUT packages to CKAN I came across
> a weird caching problem. I added a resource to a package
> (for several actually). Afterwards I used the API again to
> fix some resource formats but the newly added resource wasn't
> there anymore. So it seems I got old JSON.
> Now I am wondering what got lost even before I realized this :(

Unless there is something truly strange going on, what
is happening is this. There are two levels of caching
happening, the squid proxy and the application render
cache. The current settings mean that squid will only
ask the application for a new copy every 15 minutes.
The application will re-render the actual document only
if the resource (or something connected to it) [0] has
changed.

So if you do a pattern that looks like GET, PUT, GET
in rapit succession, the second GET will return old
data.

The cache will honour client refresh requests so if
you put the appropriate headers in (I forget what they
are exactly, the same thing your web browser will do
if you do shift-R) it will fetch a fresh copy from the
application.

Hope this helps, I'm in IRC at the moment, would be
happy to discuss in more detail if you like, or if
the problem does turn out to be something different.

Cheers,
-w

[0] see the last_modified method in ckan/model/package.py
-- 
William Waites           <william.waites at okfn.org>
Mob: +44 789 798 9965    Open Knowledge Foundation
Fax: +44 131 464 4948                Edinburgh, UK

RDF Indexing, Clustering and Inferencing in Python
		http://ordf.org/



More information about the ckan-discuss mailing list