[Developers] mqlread queries and caching

Tim Kientzle tim at metaweb.com
Mon Sep 8 20:55:11 UTC 2008


The "mwLastWriteTime" cookie specifies a "freshness constraint."  If  
you have one, we will only give you results that are at least as fresh  
as that cookie.  If it doesn't exist, then you will accept arbitrarily  
old data.  This behavior means that read-only applications will  
generally get cached data; read-write applications will see the  
results of their own writes.  Applications that need to immediately  
see writes by other applications need to do a little more work.

When you call "/api/service/touch" or perform any write operation, we  
update your mwLastWriteTime cookie so that you will only see results  
newer than your last touch or write operation.  Generally, you only  
need to call it once before a group of queries.

Tim Kientzle



On Sep 8, 2008, at 1:35 PM, Augusto Callejas wrote:

> wouldn't it be less work (one less roundtrip HTTP request) to clear  
> out the
> value of "mwLastWriteTime" instead of calling "/api/service/touch"?   
> i want
> to do a series of queries that avoid caching.
>
> thanks
> augusto
>
>
> On 9/8/08 11:21 AM, "Ben Drees" <ben at metaweb.com> wrote:
>
>> That's correct - You must track cookies for /api/service/touch to  
>> have
>> an effect.
>>
>> An individual user agent that tracks cookies will automatically  
>> read its
>> own writes.
>>
>> An individual user agent that does not track cookies may not always
>> automatically read its own writes.
>>
>> /api/service/touch is useful when one user agent needs to read the
>> results of another user agent's recent writes.
>>
>> The cache-suppressing HTTP request headers work, but may result in
>> poorer performance than with the /api/service/touch approach.
>>
>> David Flanagan wrote:
>>> Doesn't /api/service/touch work by simply returning a  
>>> nwLastWriteTime
>>> cookie?  So if you don't track the cookie in the first place, then  
>>> the
>>> touch service won't do you any good, if I understand correctly.
>>>
>>> David
>>>
>>> John Giannandrea wrote:
>>>
>>>> Augusto,
>>>> If its the same program doing the writes and the reads you should  
>>>> just
>>>> track the mwLastWriteTime cookie rather than calling /api/service/
>>>> touch every time.
>>>> -jg
>>>> On Sep 5, 2008, at 4:41 PM, Phil Gochenour wrote:
>>>>
>>>>> Hi Augusto,
>>>>>
>>>>> have a look at this Help topic and let us know if it solves the
>>>>> problem for you:
>>>>>
>>>>> Avoid caching problems when using the API
>>>>> http://www.freebase.com/view/guid/9202a8c04000641f80000000076224e8
>>>>>
>>>>> Phil


More information about the Developers mailing list