0

The following code creates Http object with caching enabled:

http = httplib2.Http('cache')
r, b = http.request('http://google.com')

The following code creates Http object with caching enabled and if the resource has already been in the cache, its never requested again:

http = httplib2.Http('cache')
r, b = http.request('http://google.com',
        headers={'cache-control':'min-fresh=-1000000000'})

How do I modify these two samples for the cache is used but never updated?

Thanks

sshilovsky
  • 958
  • 2
  • 9
  • 22

1 Answers1

0

You can pass a cache into the Http object you construct, if it implements these methods:

Cache.get(key)
Cache.set(key, value)
Cache.delete(key)

Wrap an instance of FileCache with an object that you retain a reference to. After your initial requests, change its behaviour so that get continues to work and set delegates to delete (so you never return a stale value).

Joe
  • 29,416
  • 12
  • 68
  • 88