HTTP Caching

The net.http.cache module in the Iguana Webservices repo enhances the built in net.http APIs to give an optional extra cache_time parameter.

This cache time parameter defaults to 0 seconds which means there is no caching.

If you use it though then the results of non errored HTTP calls will be cached in a local SQLite database for the number of seconds specified, i.e.

local Response = net.http.get{url=”http://www.google.com/”, cache_time=60, live=true}

This will cache for up to 60 seconds.

Why is this useful?

Sometimes web services are slow. Because the translator executes Lua code as you type this makes intellisense and annotations slower to render.

Using caching in the editor makes it faster and more convenient to develop code.

The other advantage is when you have a cloud application that has restrictive policies on how many times you can invoke their API on a daily basis. Caching locally reduces the number of calls one has to make to this application.

The module is on Github in net.http.cache in Iguana Webservices.

This shows the usage also in Github.