Posted 11 March 2014 - 11:24 PM
Hello again, everyone.
This little API was one inspired by a quick look through the Ideas Exchange in the General Forum.
It provides a simple cache for HTTP requests.
The default http.request function is unchanged, but http.get has been modified to look up a cache before making any network calls.
Both http.get and http.post will write to the cache upon success. Of course, POST requests won't use the cache.
Both functions take the same arguments their unmodified counterparts do, with the addition of an optional "cache timeout" parameter; this allows the programmer to specify how long the data written to the cache should persist.
This argument only matters if data is written back to the cache (i.e if the data in the cache is old or nonexistent).
There are also two other functions: http.clearCache and http.selectiveClearCache.
http.clearCache takes one optional parameter (a url). It will clear the specified site from the cache, and clear the entire cache if a url is not specified.
http.selectiveClearCache takes no parameters and will only clear "old" (timed out) cache entries.
Find it here.
Pastebin Code: qGX5RxDU
This little API was one inspired by a quick look through the Ideas Exchange in the General Forum.
It provides a simple cache for HTTP requests.
The default http.request function is unchanged, but http.get has been modified to look up a cache before making any network calls.
Both http.get and http.post will write to the cache upon success. Of course, POST requests won't use the cache.
Both functions take the same arguments their unmodified counterparts do, with the addition of an optional "cache timeout" parameter; this allows the programmer to specify how long the data written to the cache should persist.
This argument only matters if data is written back to the cache (i.e if the data in the cache is old or nonexistent).
There are also two other functions: http.clearCache and http.selectiveClearCache.
http.clearCache takes one optional parameter (a url). It will clear the specified site from the cache, and clear the entire cache if a url is not specified.
http.selectiveClearCache takes no parameters and will only clear "old" (timed out) cache entries.
Find it here.
Pastebin Code: qGX5RxDU
pastebin get qGX5RxDU cached_http